serverless-application-model
serverless-application-model copied to clipboard
Reusing logical ID of autogenerated HttpApi clobbers DefinitionBody
Description:
Howdy, I've noticed there appears to be some undefined behavior when using re-using the auto-generated ID of the 'AWS::Serverless::HttpApi' resource - specifically the logical ID 'ServerlessHttpApi'. I have not checked whether the REST API is affected as well.
Steps to reproduce the issue:
- Create a simple template that does not specify an 'AWS::Serverless::HttpApi', e.g. rely on auto generation by creating a serverless function type with a HttpApi event.
result: Everything works as expected
- Add the HTTP API resource and specify an OpenAPI document - e.g.;
ServerlessHttpApi:
Type: AWS::Serverless::HttpApi
Properties:
DefinitionBody:
'Fn::Transform':
Name: AWS::Include
Parameters:
Location: api.yaml
Observed Result: The lambda integration fields are present, but the body of the OpenAPI document has not been carried over to the Body property of 'AWS::ApiGatewayV2::Api`
expected: the transformed final template will include the OpenAPI definition in the 'AWS::ApiGatewayV2::Api' body field, with the lambda integration fields merged into the template.
If a logical ID is specified other than 'ServerlessHttpApi', everything works as expected; DefinitionBody and Integration definitions are merged as expected. This only seems to occurs when using the same logical ID that the auto-generated API would use.
Happy to dig in and contribute an appropriate fix if this an issue - whether that be documentation or a code change.