aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.81k stars 819 forks source link

fix: update awaiter s3 key #13872

Closed dpilch closed 1 month ago

dpilch commented 2 months ago

Description of changes

With the CDK version upgrade the runtime version of the custom resource lambda changed from 16 to 18. With the runtime change the lambda code needed be changed to account for breaking changes between 16 and 18. However, the S3 key for the zip file containing the lambda code was not changed. During the CFN deploy if the S3 key for the lambda code is unchanged the lambda code will not be updated.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html

Changes to a deployment package in Amazon S3 or a container image in ECR are not detected automatically during stack updates. To update the function code, change the object key or version in the template.

This resulted in the runtime version being upgraded to 18, but the code was not updated (and stayed with the runtime version 16 compatible implementation). The lambda would then throw errors when executed.

This change updates the lambda code s3 key to append the runtime version. This will cause the next deploy to update the lambda code because the s3 key has changed.

Changes in API repo: https://github.com/aws-amplify/amplify-category-api/pull/2732

Issue #, if available

https://github.com/aws-amplify/amplify-category-api/issues/2730

Description of how you validated changes

Manual testing. This issue only presents itself when upgrading from an earlier version of the CLI with an existing awaiter function deployed. We do not have an E2E testing framework that allows multiple versions of the CLI to be used. Adding this testing would delay the release of this fix. The tests can be added at a later time.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

dpilch commented 2 months ago

This will also need release from API category.