This repository has been archived by the owner on May 31, 2024. It is now read-only.
fix: Comment out Lambda return value to avoid nodejs14.x #637
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Closes #624
Description of Changes
Background
Lambda Functions in CDK, by default, do not create Log Groups at CDK deploy time. Log Groups are typically find-or-created when the Lambda executes for the first time.
HOWEVER, there are certain scenarios where the CloudFormation stack needs to know what the Log Group will be. For example, if the Function's log retention needs to be set to a specific value, or if some other resource needs to know the Log Group's properties.
In THESE cases, CDK will generate a
Custom::LogRetention
resource in the background, intended to set retention and return metadata about a Lambda's Log Group. You guessed it, this Custom Resource is itself a Lambda with a runtime of...drumroll...nodejs14.x
(at least in CDK2.50.0
). So that's where our problems lies.Diving Deep
The question is...why does this get created in this case at all? There's no mention of log retention ANYWHERE in this CDK application. However, careful readers may have picked up on this already: the custom resource also gets created if we're ever reading Log Group metadata. Which we're doing in each of the 4 engine constructs (eg.
amazon-genomics-cli/packages/cdk/lib/stacks/engines/cromwell-engine-construct.ts
Line 74 in d92ddc0
Solutioning
The next question is what would happen if we just...removed these offending lines of code. And the answer is...pretty much nothing. Setting
this.adapterLogGroup = lambda.logGroup
is effectively unnecessary because the only time thatadapterLogGroup
property is used is as a CfnOutput (which already has error handling if the value is undefined!!).Therefore, my proposal is to comment out these 4 lines of code. If someone wants to see the Log Group name, they can look it up from the Lambda at Lambda-execute time. I will be submitting a PR for this.
Validation
Validated using
cdk synth
locally.