Skip to content

Commit 247aa35

Browse files
authored
fix(custom-resources): fails to use latest SDK version (#29958)
### Issue # (if applicable) Closes #29891 ### Reason for this change When setting AwsCustomResource with installLatestAwsSdk: true it fails to upgrade aws-sdk to latest version. The Lambda function created to support the custom resource usually time out after 120 seconds, and for some cases it get time out even after 900 seconds. ### Description of changes Update the Lambda function created for the custom resource to set its MemorySize to be 512 in case if installLatestAwsSdk flag is true instead of the default value 128. Also, this change will expose the MemorySize to the AwsCustomResource construct, so customers can customize the MemorySize of the Lambda function to fulfill use cases that requires higher memory, CPU, or I/O performance. ### Description of how you validated changes I added the unit test cases, and updated the integration test cases. ### 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 33bf373 commit 247aa35

File tree

34 files changed

+965
-39
lines changed

34 files changed

+965
-39
lines changed

packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-athena.js.snapshot/CustomResourceAthenaDefaultTestDeployAssert7AE6A475.assets.json

+2-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/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-athena.js.snapshot/CustomResourceAthenaDefaultTestDeployAssert7AE6A475.template.json

+2-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/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-athena.js.snapshot/aws-cdk-customresources-athena.assets.json

+2-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/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-athena.js.snapshot/aws-cdk-customresources-athena.template.json

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
"S3Key": "746da84b10e215c552e68b6d2061024e4429f0386f43a35ef5e4d2940655692e.zip"
165165
},
166166
"Handler": "index.handler",
167+
"MemorySize": 512,
167168
"Role": {
168169
"Fn::GetAtt": [
169170
"CustomResourceRoleAB1EF463",

packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-athena.js.snapshot/manifest.json

+2-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/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-athena.js.snapshot/tree.json

+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/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-dynamodb.js.snapshot/AwsCustomResourceDynamoDBTestDefaultTestDeployAssertB351282D.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/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-dynamodb.js.snapshot/AwsCustomResourceDynamoDBTestDefaultTestDeployAssertB351282D.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/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-dynamodb.js.snapshot/asset.746da84b10e215c552e68b6d2061024e4429f0386f43a35ef5e4d2940655692e/index.js

+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/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-dynamodb.js.snapshot/aws-cdk-sdk-dynamodb.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,178 @@
1+
{
2+
"Resources": {
3+
"myTableA48C5C70": {
4+
"Type": "AWS::DynamoDB::Table",
5+
"Properties": {
6+
"AttributeDefinitions": [
7+
{
8+
"AttributeName": "id",
9+
"AttributeType": "S"
10+
}
11+
],
12+
"KeySchema": [
13+
{
14+
"AttributeName": "id",
15+
"KeyType": "HASH"
16+
}
17+
],
18+
"ProvisionedThroughput": {
19+
"ReadCapacityUnits": 5,
20+
"WriteCapacityUnits": 5
21+
}
22+
},
23+
"UpdateReplacePolicy": "Delete",
24+
"DeletionPolicy": "Delete"
25+
},
26+
"myCRE89CE839": {
27+
"Type": "Custom::AWS",
28+
"Properties": {
29+
"ServiceToken": {
30+
"Fn::GetAtt": [
31+
"AWS679f53fac002430cb0da5b7982bd22872D164C4C",
32+
"Arn"
33+
]
34+
},
35+
"Create": {
36+
"Fn::Join": [
37+
"",
38+
[
39+
"{\"service\":\"DynamoDB\",\"action\":\"PutItem\",\"parameters\":{\"Item\":{\"id\":{\"S\":\"test-value\"}},\"TableName\":\"",
40+
{
41+
"Ref": "myTableA48C5C70"
42+
},
43+
"\"},\"physicalResourceId\":{\"id\":\"myCRphysicalResourceID\"},\"logApiResponseData\":true}"
44+
]
45+
]
46+
},
47+
"Update": {
48+
"Fn::Join": [
49+
"",
50+
[
51+
"{\"service\":\"DynamoDB\",\"action\":\"PutItem\",\"parameters\":{\"service\":\"DynamoDB\",\"action\":\"PutItem\",\"parameters\":{\"Item\":{\"id\":{\"S\":\"test-value\"}},\"TableName\":\"",
52+
{
53+
"Ref": "myTableA48C5C70"
54+
},
55+
"\"},\"physicalResourceId\":{\"id\":\"myCRphysicalResourceID\"}},\"logApiResponseData\":true}"
56+
]
57+
]
58+
},
59+
"InstallLatestAwsSdk": true
60+
},
61+
"DependsOn": [
62+
"myCRCustomResourcePolicy05AD5A90"
63+
],
64+
"UpdateReplacePolicy": "Delete",
65+
"DeletionPolicy": "Delete"
66+
},
67+
"myCRCustomResourcePolicy05AD5A90": {
68+
"Type": "AWS::IAM::Policy",
69+
"Properties": {
70+
"PolicyDocument": {
71+
"Statement": [
72+
{
73+
"Action": "dynamodb:PutItem",
74+
"Effect": "Allow",
75+
"Resource": "*"
76+
}
77+
],
78+
"Version": "2012-10-17"
79+
},
80+
"PolicyName": "myCRCustomResourcePolicy05AD5A90",
81+
"Roles": [
82+
{
83+
"Ref": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
84+
}
85+
]
86+
}
87+
},
88+
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2": {
89+
"Type": "AWS::IAM::Role",
90+
"Properties": {
91+
"AssumeRolePolicyDocument": {
92+
"Statement": [
93+
{
94+
"Action": "sts:AssumeRole",
95+
"Effect": "Allow",
96+
"Principal": {
97+
"Service": "lambda.amazonaws.com"
98+
}
99+
}
100+
],
101+
"Version": "2012-10-17"
102+
},
103+
"ManagedPolicyArns": [
104+
{
105+
"Fn::Join": [
106+
"",
107+
[
108+
"arn:",
109+
{
110+
"Ref": "AWS::Partition"
111+
},
112+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
113+
]
114+
]
115+
}
116+
]
117+
}
118+
},
119+
"AWS679f53fac002430cb0da5b7982bd22872D164C4C": {
120+
"Type": "AWS::Lambda::Function",
121+
"Properties": {
122+
"Code": {
123+
"S3Bucket": {
124+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
125+
},
126+
"S3Key": "746da84b10e215c552e68b6d2061024e4429f0386f43a35ef5e4d2940655692e.zip"
127+
},
128+
"Handler": "index.handler",
129+
"MemorySize": 1024,
130+
"Role": {
131+
"Fn::GetAtt": [
132+
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2",
133+
"Arn"
134+
]
135+
},
136+
"Runtime": "nodejs18.x",
137+
"Timeout": 120
138+
},
139+
"DependsOn": [
140+
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
141+
]
142+
}
143+
},
144+
"Parameters": {
145+
"BootstrapVersion": {
146+
"Type": "AWS::SSM::Parameter::Value<String>",
147+
"Default": "/cdk-bootstrap/hnb659fds/version",
148+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
149+
}
150+
},
151+
"Rules": {
152+
"CheckBootstrapVersion": {
153+
"Assertions": [
154+
{
155+
"Assert": {
156+
"Fn::Not": [
157+
{
158+
"Fn::Contains": [
159+
[
160+
"1",
161+
"2",
162+
"3",
163+
"4",
164+
"5"
165+
],
166+
{
167+
"Ref": "BootstrapVersion"
168+
}
169+
]
170+
}
171+
]
172+
},
173+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
174+
}
175+
]
176+
}
177+
}
178+
}

packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-dynamodb.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/custom-resources/test/aws-custom-resource/integ.aws-custom-resource-dynamodb.js.snapshot/integ.json

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

0 commit comments

Comments
 (0)