serverless-application-model icon indicating copy to clipboard operation
serverless-application-model copied to clipboard

HTTP API duplicate integration

Open mims92 opened this issue 4 years ago • 2 comments

Description:

I want to use the same Lambda for 2 routes:

  • /api/{id}
  • /api/{id}/{proxy+}

I created 2 events in the same Serverless::Function definition. The result is that it created 2 separate integrations with the same Lambda function.

Steps to reproduce:

    ApiG:
        Type: AWS::Serverless::HttpApi
        Properties:
            CorsConfiguration:
                AllowHeaders: "*"
                AllowMethods:
                    - GET
                    - POST
                    - DELETE
                    - HEAD
                    - PUT
                    - PATCH
                AllowOrigins:
                    - '*'
                EndpointConfiguration: REGIONAL
                SecurityPolicy: TLS_1_2
            StageName: api

    ProxyServiceFunction:
        Type: AWS::Serverless::Function
        Properties:
            FunctionName: proxy
            CodeUri: proxy/src/
            Handler: index.handler
            Runtime: nodejs12.x
            Events:
                API1:
                    Type: HttpApi
                    Properties:
                        PayloadFormatVersion: "2.0"
                        Path: /api/{id}
                        Method: any
                        ApiId: !Ref ApiG
                API2:
                    Type: HttpApi
                    Properties:
                        PayloadFormatVersion: "2.0"
                        Path: /api/{id}/{proxy+}
                        Method: any
                        ApiId: !Ref ApiG

Observed result:

2 different integrations are created.

Expected result:

1 integration is created and attached to the two routes.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Debian 10
  2. If using SAM CLI, sam --version: 1.21.1
  3. AWS region: eu-central-1

mims92 avatar Mar 17 '21 20:03 mims92

Re-labeling it to a feature request. SAM creates one integration for each event even it is using the same HTTP API. We can de-duplicate such integration creations

aahung avatar Sep 13 '21 00:09 aahung

Looks like this was suppose to be on SAM Spec rather than the CLI. Moving to the correct repo.

jfuss avatar Dec 12 '22 21:12 jfuss