-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(aws-cdk-lib.aws_lambda): Lambda alias/version not updated with tokenized env var #25997
Comments
We compute the hash before the token values are known, so I'm not sure there's a way we would be able to fix this without rethinking how this construct works. |
@peterwoodworth @corymhall So there is the problem with my lambda deployment... While the Lambda function itself always updates with the new build tag parameter, the Alias remains unchanged. This seems to be because CDK doesn't account for late-bound values that can fundamentally alter the behavior of the Lambda function. As a temporary workaround, I've resorted to generating a new GUID within my source code for each stack deployment. However, it would be highly beneficial if CDK could handle this natively. What's the use case? What are we expecting? Closing Thoughts |
I just realised this and this makes me very worried about our production environments where it will be very difficult if we ever had to change an ssm-parameter. @peterwoodworth |
Ran into this with AWS Batch, passing the job definition ARN (that has a version) into a Lambda environment variable. Now I'm worried what else is miswired. Large deployment, many, many stacks and resources. |
probably related to #30093 |
The issue is still there in the latest (v2.143.0) version. Pushed a repo with the reproduction scenario: https://github.com/enpatrik/cdk-issue-25997 |
Describe the bug
When using tokenized input as a environment variable value, the Lambda alias is not automatically updated.
Expected Behavior
A new Lambda version to be created and the Lambda alias updated with the new version.
Current Behavior
The environment variables on the Lambda configuration was updated, but no new alias/version published.
Reproduction Steps
The second time the Lambda will be updated with the new environment variable under Lambda configuration.
But there won't be a new alias version published.
Same goes for other tokenized input like SSM parameter instead of CfnParameter.
When changing the value a hard coded environment variable like
HELLO: 'foo'
it will publish a new version when changing toHELLO: 'bar'
.Possible Solution
This might not be a bug, but since the documentation for addAlias https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html#aliases say:
It's a bit unexpected behaviour when the environment variable is changed and the Lambda is updated but a new version is not created.
Additional Information/Context
There was a similar issue/feature in SAM: aws/serverless-application-model#413
CDK CLI Version
2.84.0 (build f7c792f)
Framework Version
No response
Node.js Version
v18.16.0
OS
MacOS
Language
Typescript
Language Version
Typescript 5.0.4
Other information
No response
The text was updated successfully, but these errors were encountered: