Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP API duplicate integration #2720

Open
mims92 opened this issue Mar 17, 2021 · 2 comments
Open

HTTP API duplicate integration #2720

mims92 opened this issue Mar 17, 2021 · 2 comments

Comments

@mims92
Copy link

mims92 commented Mar 17, 2021

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
@CoshUS CoshUS added type/bug stage/bug-repro The issue/bug needs to be reproduced labels Mar 18, 2021
@aahung aahung added type/feature and removed type/bug stage/bug-repro The issue/bug needs to be reproduced labels Sep 13, 2021
@aahung
Copy link
Contributor

aahung commented Sep 13, 2021

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

@jfuss
Copy link
Contributor

jfuss commented Dec 12, 2022

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

@jfuss jfuss transferred this issue from aws/aws-sam-cli Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants