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

AutoPublishAlias is not triggered for environment variable changes #1305

Closed
to-mc opened this issue Dec 6, 2019 · 7 comments
Closed

AutoPublishAlias is not triggered for environment variable changes #1305

to-mc opened this issue Dec 6, 2019 · 7 comments

Comments

@to-mc
Copy link
Contributor

to-mc commented Dec 6, 2019

Description:

Changing or adding/removing environment variables for a function does not cause a new version to be published when using AutoPublishAlias.

Steps to reproduce the issue:

  1. Deploy a SAM template with an AWS::Serverless::Function resource, with AutoPublishAlias set, and including an environment variable:
HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: hello_world/
      Handler: app.lambda_handler
      Runtime: python3.8
      AutoPublishAlias: live
      Environment:
        Variables:
          TestKey: TestVal1
  1. Change TestVal1 to TestVal2.
  2. Run sam deploy .

Observed result:
The lambda function is updated with the new environment variable, but no new version is published, and the defined alias still points to the last published version.

Expected result:
A new function version is published, and the defined alias is updated to point to it.

@keetonian
Copy link
Contributor

If the lambda function is invoked, does it have the old or new value for the environment variable?

@keetonian
Copy link
Contributor

It looks like we can add the Environment dictionary to the hash that gets computed to determine if a new version needs to be published.

Section of code to update: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessapi

@to-mc
Copy link
Contributor Author

to-mc commented Dec 7, 2019

When invoking via api gateway, the "old" version without my changed env var gets invoked.

@keetonian Did you paste the right url? Was expecting a link to a section of code but your link goes to documentation.

@dalumiller
Copy link
Contributor

@cakepietoast @keetonian This is similar to the #1267 where environment variables stored in Secrets Manager that are changed don't trigger a new version of the lambda.

@to-mc
Copy link
Contributor Author

to-mc commented Jun 8, 2020

Closing this as it was resolved with #1310.

@to-mc to-mc closed this as completed Jun 8, 2020
@heyjustcode
Copy link

heyjustcode commented Dec 23, 2020

@cakepietoast this still doesn't work if the environment variable change was due to an updated value of a referenced parameter

      Environment:
        Variables:
          TEST_KEY_PARAM: !Ref ParamTestValue

@hoffa
Copy link
Contributor

hoffa commented Nov 16, 2022

@heyjustcode adding AWS::LanguageExtensions to the Transform section of your template should help, see #2533.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants