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

Feature Request: Redeploy AWS::Serverless::Api after updating a referenced parameter or metadata attribute #1605

Closed
atakidev opened this issue May 31, 2020 · 3 comments
Labels
area/intrinsics Ref, If, Sub, GetAtt, ... type/feature

Comments

@atakidev
Copy link

Description:

When AWS::Serverless::Api is used, AWS::ApiGateway::Deployment, AWS::ApiGateway::Stage are generated as described below.

SAM will generate an API Gateway Stage and API Gateway Deployment for every AWS::Serverless::Api resource.

SAM regenerates Deployment and Stage resources after updating a swagger definition. It usually works well.

However, when I use !Ref to reference a parameter in swagger definition, AWS::Serverless::Api doesn't generate Deployment and Stage resources again after updating the parameter only.

For example, the following !Ref ParamValue and updating ParamValue, the change doesn't re-generate Deployment and Stage.

Parameters:
  ParamValue:
    Type: String

Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      Name: ApiGatewayName
      StageName: Prod
      Cors: "'www.example.com'"
      DefinitionBody:
        swagger: 2.0
        basePath: /prod
        info:
          title: AwsSamExample2
          description: !Ref ParamValue
        schemes:
        - https
        paths:
          /:
            x-amazon-apigateway-any-method:

... snip ...

We may confuse there are the difference between updating parameters and editing swagger definition.

Personally, I think it is good to handle updating referenced parameters can also update Deployment and Stage resources.
Or, I think it is also good to check Metadata attribute of AWS::Serverless::Api because customer can forcefully update the resource like other CloudFormation resources described in the following page.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html#troubleshooting-errors-no-updates-to-perform

If you need to make such changes without making any other change, you can add or modify a metadata attribute for any of your resources.

Please let me know if you have any questions.

@justinmclark
Copy link

+1 This is a problem I've encountered recently as well.

@jfuss jfuss added the area/intrinsics Ref, If, Sub, GetAtt, ... label Mar 29, 2022
@hoffa
Copy link
Contributor

hoffa commented Oct 17, 2022

You might be able to get this to work by adding AWS::LanguageExtensions to Transform as such:

Transform:
  - AWS::LanguageExtensions
  - AWS::Serverless-2016-10-31

AWS::LanguageExtensions resolves intrinsic functions if the value is known when Transforms are run.

See #2533 for more information.

@hoffa
Copy link
Contributor

hoffa commented Nov 3, 2022

Closing in favor of #2533.

@hoffa hoffa closed this as completed Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/intrinsics Ref, If, Sub, GetAtt, ... type/feature
Projects
None yet
Development

No branches or pull requests

6 participants