Skip to content

Commit

Permalink
fix(codedeploy): CustomLambdaDeploymentConfig is broken (#27087)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
rix0rrr authored Sep 11, 2023
1 parent f766cee commit c53831d
Show file tree
Hide file tree
Showing 11 changed files with 422 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "34.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
{
"version": "21.0.0",
"version": "34.0.0",
"files": {
"681328df6a987c681a4d5cafad61efbf97e5934c41842c8fc92c113ee39a6b28": {
"51fc32183f8be2ed4acc5164067a61d6763acbd372aeba432deb95b9ac5b5038": {
"source": {
"path": "asset.51fc32183f8be2ed4acc5164067a61d6763acbd372aeba432deb95b9ac5b5038",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "51fc32183f8be2ed4acc5164067a61d6763acbd372aeba432deb95b9ac5b5038.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"16fed48cbbc3528cf00b892da3cd8fe72007a0ef4c7adff2fd8fdfb9c7bf0d5d": {
"source": {
"path": "aws-cdk-codedeploy-lambda-config.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "681328df6a987c681a4d5cafad61efbf97e5934c41842c8fc92c113ee39a6b28.json",
"objectKey": "16fed48cbbc3528cf00b892da3cd8fe72007a0ef4c7adff2fd8fdfb9c7bf0d5d.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,104 @@
"Type": "TimeBasedLinear"
}
}
},
"CustomConfigDeploymentConfigE9E1F384": {
"Type": "Custom::AWS",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": [
"AWS679f53fac002430cb0da5b7982bd22872D164C4C",
"Arn"
]
},
"Create": "{\"service\":\"CodeDeploy\",\"action\":\"createDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\",\"computePlatform\":\"Lambda\",\"trafficRoutingConfig\":{\"type\":\"TimeBasedLinear\",\"timeBasedLinear\":{\"linearInterval\":1,\"linearPercentage\":5}}},\"physicalResourceId\":{\"id\":\"hello\"}}",
"Update": "{\"service\":\"CodeDeploy\",\"action\":\"createDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\",\"computePlatform\":\"Lambda\",\"trafficRoutingConfig\":{\"type\":\"TimeBasedLinear\",\"timeBasedLinear\":{\"linearInterval\":1,\"linearPercentage\":5}}},\"physicalResourceId\":{\"id\":\"hello\"}}",
"Delete": "{\"service\":\"CodeDeploy\",\"action\":\"deleteDeploymentConfig\",\"parameters\":{\"deploymentConfigName\":\"hello\"}}",
"InstallLatestAwsSdk": false
},
"DependsOn": [
"CustomConfigDeploymentConfigCustomResourcePolicy0426B684"
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"CustomConfigDeploymentConfigCustomResourcePolicy0426B684": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": [
"codedeploy:CreateDeploymentConfig",
"codedeploy:DeleteDeploymentConfig"
],
"Effect": "Allow",
"Resource": "*"
}
],
"Version": "2012-10-17"
},
"PolicyName": "CustomConfigDeploymentConfigCustomResourcePolicy0426B684",
"Roles": [
{
"Ref": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
}
]
}
},
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
}
]
}
},
"AWS679f53fac002430cb0da5b7982bd22872D164C4C": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "51fc32183f8be2ed4acc5164067a61d6763acbd372aeba432deb95b9ac5b5038.zip"
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2",
"Arn"
]
},
"Runtime": "nodejs18.x",
"Timeout": 120
},
"DependsOn": [
"AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
]
}
},
"Parameters": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"21.0.0"}
{"version":"34.0.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "21.0.0",
"version": "34.0.0",
"testCases": {
"LambdaDeploymentConfigTest/DefaultTest": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"version": "21.0.0",
"version": "34.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"aws-cdk-codedeploy-lambda-config.assets": {
"type": "cdk:asset-manifest",
"properties": {
Expand All @@ -23,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/681328df6a987c681a4d5cafad61efbf97e5934c41842c8fc92c113ee39a6b28.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/16fed48cbbc3528cf00b892da3cd8fe72007a0ef4c7adff2fd8fdfb9c7bf0d5d.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand All @@ -45,6 +39,30 @@
"data": "LinearConfig531CF4AA"
}
],
"/aws-cdk-codedeploy-lambda-config/CustomConfig/DeploymentConfig/Resource/Default": [
{
"type": "aws:cdk:logicalId",
"data": "CustomConfigDeploymentConfigE9E1F384"
}
],
"/aws-cdk-codedeploy-lambda-config/CustomConfig/DeploymentConfig/CustomResourcePolicy/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "CustomConfigDeploymentConfigCustomResourcePolicy0426B684"
}
],
"/aws-cdk-codedeploy-lambda-config/AWS679f53fac002430cb0da5b7982bd2287/ServiceRole/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "AWS679f53fac002430cb0da5b7982bd2287ServiceRoleC1EA0FF2"
}
],
"/aws-cdk-codedeploy-lambda-config/AWS679f53fac002430cb0da5b7982bd2287/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "AWS679f53fac002430cb0da5b7982bd22872D164C4C"
}
],
"/aws-cdk-codedeploy-lambda-config/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
Expand Down Expand Up @@ -106,6 +124,12 @@
]
},
"displayName": "LambdaDeploymentConfigTest/DefaultTest/DeployAssert"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Loading

0 comments on commit c53831d

Please sign in to comment.