-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-s3: Unable to use Bucket.fromBucketName on legacy s3 bucket with underscore in the name #22640
aws-s3: Unable to use Bucket.fromBucketName on legacy s3 bucket with underscore in the name #22640
Comments
We do not currently support this, thanks for calling this out @NoahCarnahan, This code is checking for only letters, numbers, periods, and hyphens, and throws an error if any other character is found: aws-cdk/packages/@aws-cdk/aws-s3/lib/bucket.ts Lines 1727 to 1729 in 3528e3d
We shouldn't be throwing an error for underscores for cases like yours, so we should be checking for underscores as well here. Until we fix this, there isn't a great workaround that I can think of. Off the top of my head, you could supply an arn without the underscore, and then use the bucket normally. But make sure to use escape hatches to override the arn/name wherever your bucket arn or name is passed in (you can view the template to see where your imported bucket is being used exactly by seeing where its arn is in the template) |
I'd like to fix this. @peterwoodworth I see why this would have been a bad idea. |
I see why this would have been a bad idea. |
Thanks both for looking into this |
|
1 similar comment
|
Describe the bug
I'm attempting to reference an s3 bucket in my cdk code that was created years ago outside of cdk. The bucket has an underscore in its name, which was legal for buckets before March 1, 2018 (new buckets can't have underscores in their names). I've tried referencing the bucket with both
Bucket.fromBucketName
andBucket.fromBucketAttributes
, but both throw this error:(note that I've censored the actual bucket name for privacy)
Also note that I'm using the python version of the cdk library. Is there any way I can reference this bucket from CDK?
Expected Behavior
I expect to be able to import the bucket.
Current Behavior
Error message is:
Stack trace (paths modified for privacy)
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.46.0 (build 5a0595e)
Framework Version
No response
Node.js Version
v18.0.0
OS
macOS 12.6
Language
Python
Language Version
Python 3.9.12
Other information
No response
The text was updated successfully, but these errors were encountered: