Skip to content

Commit 919d16f

Browse files
authored
fix(lambda-nodejs): fixing esbuildArgs to take in account re-specified keys (#29167)
### Issue # (if applicable) Closes #25385 ### Reason for this change This PR fixes a bug in CDK where CDK does not take into account re-specified keys while doing bundling. The CLI supports flags in one of three forms: `--foo`, `--foo=bar`, or `--foo:bar`. However, the `--foo:bar` form was not initially supported. With `--foo:bar`, users can now specify flags that have multiple values and can be re-specified multiple times. ### Description of changes The code has a list of keys that can be re-specified multiple times. While assigning the flags it checks whether the key is among the list of re-specified keys, if yes, it specifies the flag with `:`. ### Description of how you validated changes The PR includes unit test and integration test both to validate the changes. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent baaa50c commit 919d16f

File tree

13 files changed

+588
-1
lines changed

13 files changed

+588
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.esbuildArgs.js.snapshot/LambdaNodeJsEsbuildArgsIntegDefaultTestDeployAssertB1F5AACE.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.esbuildArgs.js.snapshot/LambdaNodeJsEsbuildArgsIntegDefaultTestDeployAssertB1F5AACE.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.esbuildArgs.js.snapshot/asset.5017e4b2e278e32bc634202d075b7ed8961b0d784f75450f7918a6a4f6f7df4a/index.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.esbuildArgs.js.snapshot/asset.5017e4b2e278e32bc634202d075b7ed8961b0d784f75450f7918a6a4f6f7df4a/index.js.map

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.esbuildArgs.js.snapshot/cdk-integ-lambda-nodejs-esbuildArgs.assets.json

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"Resources": {
3+
"tshandlerServiceRole8876B8E7": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
28+
]
29+
]
30+
}
31+
]
32+
}
33+
},
34+
"tshandler4E1C6929": {
35+
"Type": "AWS::Lambda::Function",
36+
"Properties": {
37+
"Code": {
38+
"S3Bucket": {
39+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
40+
},
41+
"S3Key": "5017e4b2e278e32bc634202d075b7ed8961b0d784f75450f7918a6a4f6f7df4a.zip"
42+
},
43+
"Environment": {
44+
"Variables": {
45+
"AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1"
46+
}
47+
},
48+
"Handler": "index.handler",
49+
"Role": {
50+
"Fn::GetAtt": [
51+
"tshandlerServiceRole8876B8E7",
52+
"Arn"
53+
]
54+
},
55+
"Runtime": "nodejs18.x"
56+
},
57+
"DependsOn": [
58+
"tshandlerServiceRole8876B8E7"
59+
]
60+
}
61+
},
62+
"Parameters": {
63+
"BootstrapVersion": {
64+
"Type": "AWS::SSM::Parameter::Value<String>",
65+
"Default": "/cdk-bootstrap/hnb659fds/version",
66+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
67+
}
68+
},
69+
"Rules": {
70+
"CheckBootstrapVersion": {
71+
"Assertions": [
72+
{
73+
"Assert": {
74+
"Fn::Not": [
75+
{
76+
"Fn::Contains": [
77+
[
78+
"1",
79+
"2",
80+
"3",
81+
"4",
82+
"5"
83+
],
84+
{
85+
"Ref": "BootstrapVersion"
86+
}
87+
]
88+
}
89+
]
90+
},
91+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
92+
}
93+
]
94+
}
95+
}
96+
}

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.esbuildArgs.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.esbuildArgs.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.esbuildArgs.js.snapshot/manifest.json

+119
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)