Skip to content

Commit c53831d

Browse files
authored
fix(codedeploy): CustomLambdaDeploymentConfig is broken (#27087)
Since the conversion of SDKv2 to SDKv3 of the `AwsCustomResource`, this custom resource was broken with the following error: ``` SerializationException: STRING_VALUE can not be converted to an Integer ``` The reason is that SDKv2 used to accept strings and coerce them to numbers wherever necessary, but SDKv3 does not do this anymore. Update the Custom Resource usage to no longer stringify the numbers. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f766cee commit c53831d

File tree

11 files changed

+422
-37
lines changed

11 files changed

+422
-37
lines changed

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/LambdaDeploymentConfigTestDefaultTestDeployAssert161B09F6.assets.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "21.0.0",
2+
"version": "34.0.0",
33
"files": {
44
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
55
"source": {

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/asset.51fc32183f8be2ed4acc5164067a61d6763acbd372aeba432deb95b9ac5b5038/index.js

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

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/aws-cdk-codedeploy-lambda-config.assets.json

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
{
2-
"version": "21.0.0",
2+
"version": "34.0.0",
33
"files": {
4-
"681328df6a987c681a4d5cafad61efbf97e5934c41842c8fc92c113ee39a6b28": {
4+
"51fc32183f8be2ed4acc5164067a61d6763acbd372aeba432deb95b9ac5b5038": {
5+
"source": {
6+
"path": "asset.51fc32183f8be2ed4acc5164067a61d6763acbd372aeba432deb95b9ac5b5038",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "51fc32183f8be2ed4acc5164067a61d6763acbd372aeba432deb95b9ac5b5038.zip",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
},
17+
"16fed48cbbc3528cf00b892da3cd8fe72007a0ef4c7adff2fd8fdfb9c7bf0d5d": {
518
"source": {
619
"path": "aws-cdk-codedeploy-lambda-config.template.json",
720
"packaging": "file"
821
},
922
"destinations": {
1023
"current_account-current_region": {
1124
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "681328df6a987c681a4d5cafad61efbf97e5934c41842c8fc92c113ee39a6b28.json",
25+
"objectKey": "16fed48cbbc3528cf00b892da3cd8fe72007a0ef4c7adff2fd8fdfb9c7bf0d5d.json",
1326
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1427
}
1528
}

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/aws-cdk-codedeploy-lambda-config.template.json

+98
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,104 @@
1212
"Type": "TimeBasedLinear"
1313
}
1414
}
15+
},
16+
"CustomConfigDeploymentConfigE9E1F384": {
17+
"Type": "Custom::AWS",
18+
"Properties": {
19+
"ServiceToken": {
20+
"Fn::GetAtt": [
21+
"AWS679f53fac002430cb0da5b7982bd22872D164C4C",
22+
"Arn"
23+
]
24+
},
25+
"Create": "{\"service\":\"CodeDeploy\",\"action\":\"createDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\",\"computePlatform\":\"Lambda\",\"trafficRoutingConfig\":{\"type\":\"TimeBasedLinear\",\"timeBasedLinear\":{\"linearInterval\":1,\"linearPercentage\":5}}},\"physicalResourceId\":{\"id\":\"hello\"}}",
26+
"Update": "{\"service\":\"CodeDeploy\",\"action\":\"createDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\",\"computePlatform\":\"Lambda\",\"trafficRoutingConfig\":{\"type\":\"TimeBasedLinear\",\"timeBasedLinear\":{\"linearInterval\":1,\"linearPercentage\":5}}},\"physicalResourceId\":{\"id\":\"hello\"}}",
27+
"Delete": "{\"service\":\"CodeDeploy\",\"action\":\"deleteDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\"}}",
28+
"InstallLatestAwsSdk": false
29+
},
30+
"DependsOn": [
31+
"CustomConfigDeploymentConfigCustomResourcePolicy0426B684"
32+
],
33+
"UpdateReplacePolicy": "Delete",
34+
"DeletionPolicy": "Delete"
35+
},
36+
"CustomConfigDeploymentConfigCustomResourcePolicy0426B684": {
37+
"Type": "AWS::IAM::Policy",
38+
"Properties": {
39+
"PolicyDocument": {
40+
"Statement": [
41+
{
42+
"Action": [
43+
"codedeploy:CreateDeploymentConfig",
44+
"codedeploy:DeleteDeploymentConfig"
45+
],
46+
"Effect": "Allow",
47+
"Resource": "*"
48+
}
49+
],
50+
"Version": "2012-10-17"
51+
},
52+
"PolicyName": "CustomConfigDeploymentConfigCustomResourcePolicy0426B684",
53+
"Roles": [
54+
{
55+
"Ref": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
56+
}
57+
]
58+
}
59+
},
60+
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2": {
61+
"Type": "AWS::IAM::Role",
62+
"Properties": {
63+
"AssumeRolePolicyDocument": {
64+
"Statement": [
65+
{
66+
"Action": "sts:AssumeRole",
67+
"Effect": "Allow",
68+
"Principal": {
69+
"Service": "lambda.amazonaws.com"
70+
}
71+
}
72+
],
73+
"Version": "2012-10-17"
74+
},
75+
"ManagedPolicyArns": [
76+
{
77+
"Fn::Join": [
78+
"",
79+
[
80+
"arn:",
81+
{
82+
"Ref": "AWS::Partition"
83+
},
84+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
85+
]
86+
]
87+
}
88+
]
89+
}
90+
},
91+
"AWS679f53fac002430cb0da5b7982bd22872D164C4C": {
92+
"Type": "AWS::Lambda::Function",
93+
"Properties": {
94+
"Code": {
95+
"S3Bucket": {
96+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
97+
},
98+
"S3Key": "51fc32183f8be2ed4acc5164067a61d6763acbd372aeba432deb95b9ac5b5038.zip"
99+
},
100+
"Handler": "index.handler",
101+
"Role": {
102+
"Fn::GetAtt": [
103+
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2",
104+
"Arn"
105+
]
106+
},
107+
"Runtime": "nodejs18.x",
108+
"Timeout": 120
109+
},
110+
"DependsOn": [
111+
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
112+
]
15113
}
16114
},
17115
"Parameters": {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"21.0.0"}
1+
{"version":"34.0.0"}

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/integ.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "21.0.0",
2+
"version": "34.0.0",
33
"testCases": {
44
"LambdaDeploymentConfigTest/DefaultTest": {
55
"stacks": [

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-codedeploy/test/lambda/integ.deployment-config.js.snapshot/manifest.json

+32-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{
2-
"version": "21.0.0",
2+
"version": "34.0.0",
33
"artifacts": {
4-
"Tree": {
5-
"type": "cdk:tree",
6-
"properties": {
7-
"file": "tree.json"
8-
}
9-
},
104
"aws-cdk-codedeploy-lambda-config.assets": {
115
"type": "cdk:asset-manifest",
126
"properties": {
@@ -23,7 +17,7 @@
2317
"validateOnSynth": false,
2418
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
2519
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
26-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/681328df6a987c681a4d5cafad61efbf97e5934c41842c8fc92c113ee39a6b28.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/16fed48cbbc3528cf00b892da3cd8fe72007a0ef4c7adff2fd8fdfb9c7bf0d5d.json",
2721
"requiresBootstrapStackVersion": 6,
2822
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2923
"additionalDependencies": [
@@ -45,6 +39,30 @@
4539
"data": "LinearConfig531CF4AA"
4640
}
4741
],
42+
"/aws-cdk-codedeploy-lambda-config/CustomConfig/DeploymentConfig/Resource/Default": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "CustomConfigDeploymentConfigE9E1F384"
46+
}
47+
],
48+
"/aws-cdk-codedeploy-lambda-config/CustomConfig/DeploymentConfig/CustomResourcePolicy/Resource": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "CustomConfigDeploymentConfigCustomResourcePolicy0426B684"
52+
}
53+
],
54+
"/aws-cdk-codedeploy-lambda-config/AWS679f53fac002430cb0da5b7982bd2287/ServiceRole/Resource": [
55+
{
56+
"type": "aws:cdk:logicalId",
57+
"data": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
58+
}
59+
],
60+
"/aws-cdk-codedeploy-lambda-config/AWS679f53fac002430cb0da5b7982bd2287/Resource": [
61+
{
62+
"type": "aws:cdk:logicalId",
63+
"data": "AWS679f53fac002430cb0da5b7982bd22872D164C4C"
64+
}
65+
],
4866
"/aws-cdk-codedeploy-lambda-config/BootstrapVersion": [
4967
{
5068
"type": "aws:cdk:logicalId",
@@ -106,6 +124,12 @@
106124
]
107125
},
108126
"displayName": "LambdaDeploymentConfigTest/DefaultTest/DeployAssert"
127+
},
128+
"Tree": {
129+
"type": "cdk:tree",
130+
"properties": {
131+
"file": "tree.json"
132+
}
109133
}
110134
}
111135
}

0 commit comments

Comments
 (0)