-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lambda): invalid Version object created from Version.fromVersionA…
…rn (#31433) ### Issue # (if applicable) Closes #29813 ### Reason for this change The current `lambda.Version.fromVersionArn` will incorrectly create the lambda function arn with the version qualifier. This is incorrect behaviour and cause CFN deployment failures. ### Description of changes If the version arn is an unresolved token, use intrinsics to join the first 7 components. Otherwise, split the array and join the first 7 components directly. ### Description of how you validated changes All new and existing tests should pass. New integration tests added with assertions. ### Checklist - [ ] 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*
- Loading branch information
Showing
12 changed files
with
32,687 additions
and
2 deletions.
There are no files selected for viewing
31,546 changes: 31,546 additions & 0 deletions
31,546
...ot/asset.3cef2cdbb46b3821e641ffb8b9af9731af5f7e4a9e857ab633dbcd9023de724d.bundle/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...testing/framework-integ/test/aws-lambda/test/integ.lambda-version-arn.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...ting/framework-integ/test/aws-lambda/test/integ.lambda-version-arn.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
.../test/aws-lambda/test/integ.lambda-version-arn.js.snapshot/lambda-version-arn.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
135 changes: 135 additions & 0 deletions
135
...est/aws-lambda/test/integ.lambda-version-arn.js.snapshot/lambda-version-arn.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
{ | ||
"Resources": { | ||
"FnServiceRoleB9001A96": { | ||
"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" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"Fn9270CBC0": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "foo" | ||
}, | ||
"Handler": "index.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"FnServiceRoleB9001A96", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "python3.10" | ||
}, | ||
"DependsOn": [ | ||
"FnServiceRoleB9001A96" | ||
] | ||
}, | ||
"Version6A868472": { | ||
"Type": "AWS::Lambda::Version", | ||
"Properties": { | ||
"FunctionName": { | ||
"Ref": "Fn9270CBC0" | ||
} | ||
} | ||
}, | ||
"VersionEventInvokeConfig19A99EDA": { | ||
"Type": "AWS::Lambda::EventInvokeConfig", | ||
"Properties": { | ||
"FunctionName": { | ||
"Ref": "Fn9270CBC0" | ||
}, | ||
"MaximumEventAgeInSeconds": 3600, | ||
"MaximumRetryAttempts": 0, | ||
"Qualifier": { | ||
"Fn::GetAtt": [ | ||
"Version6A868472", | ||
"Version" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"Outputs": { | ||
"VersionArn": { | ||
"Value": { | ||
"Ref": "Version6A868472" | ||
} | ||
}, | ||
"FunctionArn1": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Fn9270CBC0", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
"FunctionArn2": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Fn9270CBC0", | ||
"Arn" | ||
] | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...g.lambda-version-arn.js.snapshot/lambdaversionDefaultTestDeployAssert7B4F8B2D.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.