feat(cli): support hotswapping Lambda functions with inline code#18408
feat(cli): support hotswapping Lambda functions with inline code#18408mergify[bot] merged 11 commits intoaws:masterfrom
Conversation
packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts
Show resolved
Hide resolved
packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts
Show resolved
Hide resolved
| // We must create a zip package containing a file with the inline code | ||
| const rawZipFile = await evaluateCfnTemplate.evaluateCfnExpression(updatedProp.newValue[newPropName]); | ||
| // file extension must be chosen depending on the runtime | ||
| const runtime: string = await evaluateCfnTemplate.evaluateCfnExpression(change.newValue.Properties!.Runtime); |
There was a problem hiding this comment.
Is the ! really required? Can we go without it?
| const runtime: string = await evaluateCfnTemplate.evaluateCfnExpression(change.newValue.Properties!.Runtime); | |
| const runtime: string = await evaluateCfnTemplate.evaluateCfnExpression(change.newValue.Properties.Runtime); |
There was a problem hiding this comment.
Also, let's call this variable functionRuntime, just to make it's very clear what runtime we are talking about here.
There was a problem hiding this comment.
Properties is possibly undefined so we need to care it.
aws-cdk/packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts
Lines 475 to 480 in c7c51de
I replaced ! to ? to care when runtime is undefined, c.f. s3-bucket-deployments.ts (idk if there's such a case though)
aws-cdk/packages/aws-cdk/lib/api/hotswap/s3-bucket-deployments.ts
Lines 25 to 28 in c7c51de
packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-cdk/test/api/hotswap/lambda-functions-inline-hotswap-deployments.test.ts
Show resolved
Hide resolved
Pull request has been modified.
|
@skinny85 |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…#18408) Similarly to aws#18319, this PR supports hotswap of Lambda functions that use `InlineCode`. `InlineCode` uses [CloudFormation `ZipFile` feature](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#:~:text=requires%3A%20No%20interruption-,ZipFile,-\(Node.js%20and). To emulate its behavior, we create a zip file of the provided inline code with its filename `index.js` or `index.py` according to the runtime (CFn only supports python or nodejs for ZipFile), and pass the file's binary buffer to Lambda API. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Similarly to #18319, this PR supports hotswap of Lambda functions that use
InlineCode.InlineCodeuses CloudFormationZipFilefeature. To emulate its behavior, we create a zip file of the provided inline code with its filenameindex.jsorindex.pyaccording to the runtime (CFn only supports python or nodejs for ZipFile), and pass the file's binary buffer to Lambda API.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license