Skip to content

AWS::Serverless::Api deployment resource is not generated on Sub'ed Ref change #914

@tommyvn

Description

@tommyvn
  1. Deploy the attached Cloudformation template, see that visiting the API GW address shows the text in the RandomParameter CF parameter.
  2. Update the stack and change the RandomParameter value, see that a new Deployment resource is not created by the Serverless transform and see that visiting the API GW address shows the previous value of RandomParameter rather than the expected current one.

Thinking about this in the context of my own custom transform I get why detecting the change in the ref is difficult in a transform, with it being a layer removed, but the UX confused me, my VTL changed so why didn't it deploy was my initial reaction.

I suspect this suggestion won't fly but I'm making it anyway: could you generate a new Deployment on every transform regardless of if the Api resource has changed or not? It feels like a safe choice, worst case it's a noop deployment, best case it means !Refs and !Subs and !Ifs within the transformed resource work intuitively.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Parameters:
  RandomParameter:
    Type: String

Resources:
  Api:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      DefinitionBody:
        swagger: '2.0'
        schemes:
        - https
        paths:
          "/":
            get:
              consumes:
              - application/json
              produces:
              - text/html
              responses:
                '200':
                  description: Successful operation
                  headers:
                    Content-Type:
                      type: string
              x-amazon-apigateway-integration:
                responses:
                  default:
                    statusCode: '200'
                    responseParameters:
                      method.response.header.Content-Type: "'text/html'"
                    responseTemplates:
                      text/html: !Sub |-
                        <html>
                            <body>
                                <h1>${RandomParameter}</h1>
                            </body>
                        </html>
                passthroughBehavior: when_no_match
                requestTemplates:
                  application/json: '{"statusCode": 200}'
                type: mock

Outputs:
  Url:
    Value: !Sub https://${Api}.execute-api.${AWS::Region}.amazonaws.com/Prod

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions