-
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
(cli): Hotswapping support for Lambda function's description and or environment variable #20787
Comments
…ronment variables (#21305) This change allows Lambda function to be hotswap'ed when there's change in the function's description and/or environment variables. These changes are categorized as configuration changes and are updated by calling `updateFunctionConfiguration`. Since the existing waiter "UpdateFunctionCodeToFinish" is now used to wait for both code update and configuration update, I renamed it to "UpdateFunctionPropertiesToFinish". resolves #20787 ---- ### All Submissions: * [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…ronment variables (aws#21305) This change allows Lambda function to be hotswap'ed when there's change in the function's description and/or environment variables. These changes are categorized as configuration changes and are updated by calling `updateFunctionConfiguration`. Since the existing waiter "UpdateFunctionCodeToFinish" is now used to wait for both code update and configuration update, I renamed it to "UpdateFunctionPropertiesToFinish". resolves aws#20787 ---- ### All Submissions: * [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
PR needed to be reverted due to a failure with integration tests |
…ronment variables (#21532) CDK users who deploy their Lambda function with S3 code provider cannot use hotswap deployment today. It's because -- in order for the function version and alias to work -- they need to use a dynamic value in either function's description or environment variable. Since neither of them is supported by hotswap, CDK always performs a full deployment. This change allows Lambda function to be hotswappable when there's change in the function's description and/or environment variables. These changes are categorized as configuration changes and are updated by calling `updateFunctionConfiguration`. Since the existing waiter `UpdateFunctionCodeToFinish` is now used to wait for both code update and configuration update, I renamed it to `UpdateFunctionPropertiesToFinish`. Functional wise, this PR is identical to the now-reverted changes in #21305. The only difference is the fix for integration test (commit [#82dbd4)](82dbd41) resolves #20787 ---- #21305 ### All Submissions: * [ X ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ X ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…ronment variables (aws#21305) This change allows Lambda function to be hotswap'ed when there's change in the function's description and/or environment variables. These changes are categorized as configuration changes and are updated by calling `updateFunctionConfiguration`. Since the existing waiter "UpdateFunctionCodeToFinish" is now used to wait for both code update and configuration update, I renamed it to "UpdateFunctionPropertiesToFinish". resolves aws#20787 ---- ### All Submissions: * [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…ronment variables (aws#21532) CDK users who deploy their Lambda function with S3 code provider cannot use hotswap deployment today. It's because -- in order for the function version and alias to work -- they need to use a dynamic value in either function's description or environment variable. Since neither of them is supported by hotswap, CDK always performs a full deployment. This change allows Lambda function to be hotswappable when there's change in the function's description and/or environment variables. These changes are categorized as configuration changes and are updated by calling `updateFunctionConfiguration`. Since the existing waiter `UpdateFunctionCodeToFinish` is now used to wait for both code update and configuration update, I renamed it to `UpdateFunctionPropertiesToFinish`. Functional wise, this PR is identical to the now-reverted changes in aws#21305. The only difference is the fix for integration test (commit [#82dbd4)](aws@82dbd41) resolves aws#20787 ---- aws#21305 ### All Submissions: * [ X ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ X ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the feature
Lambda users are hitting a situation with hotswap deployment where either (1) hotswap deployment is always skipped or (2) it is not compatible with subsequent full deployments.
Use Case
The issue happens with a setup where:
lambda.Code.fromBucket
)--hotswap
directive.For that setup, we suggest in our doc that users should define a
lambda.Version
directly:We also say that we should apply some trick to the
Function
resource's properties so theVersion
can be updated properlyThere are at least three ways of doing it with CDK, but every of them gives users error at some point in their development cycle.
Option 1: Adding a dynamic environment variable
This option is suggested in the official doc. An example code looks like this:
Since Function's environment update is not considered hotswappable, user can never perform a hotswap deployment with this code. In my local setup where the hotswap deployment was skipped, this was the diff for this case:
Option 2: Adding a dynamic value to the function description
If I recall correctly, one example in AWS CDK docs was using this approach, but that snippet is now deleted. But this is a commonly known trick to mutate the Lambda function's properties:
This option has the same problem as option #1 -- hotswap deployment is always skipped because an update of a Lambda function's description is not a hotswappable change.
Option 3: Making the Version resource dynamic instead
This option was used as an example by the CDK folks in a comment on a similar topic in the past:
This trick does allow hotswap deployment to work, but will cause every subsequent full deployment to fail because of conflicting function version. Example error message:
Proposed Solution
If we could make option 3 works, that would be ideal. However, it require users to have access to a value that changes consistently with the Lambda code (such as the hash of the Lambda code or the local build version). And that value has to be available at synthesis time. This is not feasible for many users.
So we are left with the options of making Lambda function's descriptions and/or environment variables hotswappable. That said, there may be better options that I haven't thought of yet.
Other Information
No response
Acknowledgements
CDK version used
2.28.1 (build d035432)
Environment details (OS name and version, etc.)
Darwin Kernel Version 21.5.0 . root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64
The text was updated successfully, but these errors were encountered: