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

Adding "FunctionName" to AWS::Serverless::Function does not trigger an API Gateway deployment #739

Closed
booniepepper opened this issue Dec 28, 2018 · 1 comment

Comments

@booniepepper
Copy link

booniepepper commented Dec 28, 2018

Description:

Adding (or removing) FunctionName property to an AWS::Serverless::Function doesn't trigger an API Gateway deployment. This means executing a change set that adds a function name will cause API Gateways pointing to a Lambda Function to cease connecting. (In other words, the APIs will continue to point to a previous Lambda Function name and never update to the new name)

Steps to reproduce the issue:

  1. Write a template to deploy an AWS::Serverless::Api backed by an AWS::Serverless::Function
  2. Deploy the template
  3. Make some calls to the API - it will work
  4. Make a change set that adds a FunctionName property to the AWS::Serverless::Function
  5. Deploy the template
  6. Make some calls to the API -nothing connects

This also breaks in reverse, by removing a FunctionName property. (Meaning it's not possible to "roll back" since auto-generated names will not match before and after this action.)

Note: If anyone else experiences this, you can at least manually re-deploy the API Gateway stage for an immediate fix. (through the web console, CLI, or the SDKs)

Observed result:

API Gateway fails all calls to its resources with 500 errors.

Expected result:

API Gateway is deployed with its APIs pointing to new Lambdas.

Best case scenario, we'd be able to make use of Lambda aliases and CodeDeploy to make the switch seemlessly. Otherwise, some brief outage during the switch would be preferable to the current behavior of "breaks and never works without a manual deployment"

@jlhood
Copy link
Contributor

jlhood commented Jan 8, 2019

This is another flavor of #479. SAM only generates a new API Gateway Deployment if the swagger definition changes. If SAM uses an intrinsic function inside the swagger definition, the definition is not seen as changed, even if the value returned by the intrinsic function changes. Here's an example SAM output showing that the Function's ARN is put into the swagger definition using intrinsic functions:

https://github.com/awslabs/serverless-application-model/blob/master/tests/translator/output/implicit_api.json#L285

So when you change the FunctionName property, it doesn't change the actual swagger definition. A workaround for your specific case is to change the logical name of the resource.

Closing this in favor of #479

@jlhood jlhood closed this as completed Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants