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

Reusing logical ID of autogenerated HttpApi clobbers DefinitionBody

Open matt-tyler opened this issue 5 years ago • 0 comments

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:

  1. 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

  1. 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.

matt-tyler avatar Jan 14 '20 23:01 matt-tyler