-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Describe the bug
I'm attempting to reference an s3 bucket in my cdk code that was created in 2013 outside of cdk. The bucket has Capital letters in its name, which was legal for buckets before March 1, 2018 (new buckets can't have Capital letters or underscores in their names). I've tried referencing the bucket with both Bucket.fromBucketName and Bucket.fromBucketAttributes, but both throw this error:
(note that I've slightly changed the name of the actual bucket for privacy)
Error: Invalid S3 bucket name (value: ABCD_Central_1)
Bucket name must only contain lowercase characters and the symbols, period (.), underscore (_), and dash (-) (offset: 0)
Bucket name must start and end with a lowercase character or number (offset: 0)
at Function.validateBucketName (cdk-bug-test/node_modules/aws-cdk-lib/aws-s3/lib/bucket.js:1:19752)
at Function.fromBucketAttributes (cdk-bug-test/node_modules/aws-cdk-lib/aws-s3/lib/bucket.js:1:15111)
at Function.fromBucketName (cdk-bug-test/node_modules/aws-cdk-lib/aws-s3/lib/bucket.js:1:14511)
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
No response
Expected Behavior
I expect to be able to import the bucket.
Current Behavior
See error message in the description
Reproduction Steps
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
export class CdkBugTestStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
//
let bucket = cdk.aws_s3.Bucket.fromBucketName(this, 'test-bucket', 'ABCD_Central_1');
// also didnt work
//let fromBucketName = cdk.aws_s3.Bucket.fromBucketArn(this, 'test-bucket', 'arn:aws:s3:::ABCD_Central_1');
/*let fromBucketName = cdk.aws_s3.Bucket.fromBucketAttributes(this, 'test-bucket', {
bucketName: 'NDAR_Central_1'
});*/
}
}
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.161.1
Framework Version
No response
Node.js Version
v20.15.0
OS
Ubuntu via (Window Subsystem for Linux)
Language
TypeScript
Language Version
No response
Other information
No response