Skip to content

Commit e09126f

Browse files
authored
fix(s3): allow import S3 bucket with a legacy name (#30679)
### Issue # (if applicable) Closes #22640. ### Reason for this change Customers could not imported S3 bucket that has a legacy name (contains underscore in the name) and use it in CDK Apps. ### Description of changes This change allowed customer to use S3 buckets legacy names for only the imported S3 buckets, but not for the new ones. ### Description of how you validated changes Added unit test cases, and 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 0aa2be7 commit e09126f

12 files changed

+637
-4
lines changed

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-s3/test/integ.bucket-legacy-naming.js.snapshot/aws-cdk-s3-legacy-name-integ.assets.json

+19
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,102 @@
1+
{
2+
"Resources": {
3+
"LegacyBucketRoleFF9F72AB": {
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+
}
19+
},
20+
"LegacyBucketRoleDefaultPolicyA9F22E7C": {
21+
"Type": "AWS::IAM::Policy",
22+
"Properties": {
23+
"PolicyDocument": {
24+
"Statement": [
25+
{
26+
"Action": "s3:*",
27+
"Effect": "Allow",
28+
"Resource": [
29+
"arn:aws:s3:::my_legacy_bucket2/*",
30+
{
31+
"Fn::Join": [
32+
"",
33+
[
34+
"arn:",
35+
{
36+
"Ref": "AWS::Partition"
37+
},
38+
":s3:::my_legacy_bucket1/*"
39+
]
40+
]
41+
},
42+
{
43+
"Fn::Join": [
44+
"",
45+
[
46+
"arn:",
47+
{
48+
"Ref": "AWS::Partition"
49+
},
50+
":s3:::my_legacy_bucket3/*"
51+
]
52+
]
53+
}
54+
]
55+
}
56+
],
57+
"Version": "2012-10-17"
58+
},
59+
"PolicyName": "LegacyBucketRoleDefaultPolicyA9F22E7C",
60+
"Roles": [
61+
{
62+
"Ref": "LegacyBucketRoleFF9F72AB"
63+
}
64+
]
65+
}
66+
}
67+
},
68+
"Parameters": {
69+
"BootstrapVersion": {
70+
"Type": "AWS::SSM::Parameter::Value<String>",
71+
"Default": "/cdk-bootstrap/hnb659fds/version",
72+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
73+
}
74+
},
75+
"Rules": {
76+
"CheckBootstrapVersion": {
77+
"Assertions": [
78+
{
79+
"Assert": {
80+
"Fn::Not": [
81+
{
82+
"Fn::Contains": [
83+
[
84+
"1",
85+
"2",
86+
"3",
87+
"4",
88+
"5"
89+
],
90+
{
91+
"Ref": "BootstrapVersion"
92+
}
93+
]
94+
}
95+
]
96+
},
97+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
98+
}
99+
]
100+
}
101+
}
102+
}

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-s3/test/integ.bucket-legacy-naming.js.snapshot/awscdks3integtestDefaultTestDeployAssert9DECDFBF.assets.json

+19
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-s3/test/integ.bucket-legacy-naming.js.snapshot/awscdks3integtestDefaultTestDeployAssert9DECDFBF.template.json

+36
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-s3/test/integ.bucket-legacy-naming.js.snapshot/cdk.out

+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-s3/test/integ.bucket-legacy-naming.js.snapshot/integ.json

+12
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-s3/test/integ.bucket-legacy-naming.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)