serverless-application-model
serverless-application-model copied to clipboard
HTTP API duplicate integration
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)
- OS: Debian 10
- If using SAM CLI,
sam --version: 1.21.1 - AWS region: eu-central-1
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
Looks like this was suppose to be on SAM Spec rather than the CLI. Moving to the correct repo.