Skip to content

Commit

Permalink
fix(s3): allow import S3 bucket with a legacy name (#30679)
Browse files Browse the repository at this point in the history
### 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*
  • Loading branch information
moelasmar authored Jun 27, 2024
1 parent 0aa2be7 commit e09126f
Show file tree
Hide file tree
Showing 12 changed files with 637 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"Resources": {
"LegacyBucketRoleFF9F72AB": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
}
}
},
"LegacyBucketRoleDefaultPolicyA9F22E7C": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "s3:*",
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::my_legacy_bucket2/*",
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":s3:::my_legacy_bucket1/*"
]
]
},
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":s3:::my_legacy_bucket3/*"
]
]
}
]
}
],
"Version": "2012-10-17"
},
"PolicyName": "LegacyBucketRoleDefaultPolicyA9F22E7C",
"Roles": [
{
"Ref": "LegacyBucketRoleFF9F72AB"
}
]
}
}
},
"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."
}
]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e09126f

Please sign in to comment.