Skip to content
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

fix(aws-s3): unable to use bucket from bucket name on legacy s3 bucket with underscore in the name #22797

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-s3/lib/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1724,9 +1724,9 @@ export class Bucket extends BucketBase {
if (bucketName.length < 3 || bucketName.length > 63) {
errors.push('Bucket name must be at least 3 and no more than 63 characters');
}
const charsetMatch = bucketName.match(/[^a-z0-9.-]/);
const charsetMatch = bucketName.match(/[^a-z0-9_.-]/);
if (charsetMatch) {
errors.push('Bucket name must only contain lowercase characters and the symbols, period (.) and dash (-) '
errors.push('Bucket name must only contain lowercase characters and the symbols, period (.), underscore(_), and dash (-) '
+ `(offset: ${charsetMatch.index})`);
}
if (!/[a-z0-9]/.test(bucketName.charAt(0))) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-s3/test/bucket.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('bucket', () => {
const expectedErrors = [
`Invalid S3 bucket name (value: ${bucket})`,
'Bucket name must be at least 3 and no more than 63 characters',
'Bucket name must only contain lowercase characters and the symbols, period (.) and dash (-) (offset: 5)',
'Bucket name must only contain lowercase characters and the symbols, period (.), underscore(_), and dash (-) (offset: 5)',
'Bucket name must start and end with a lowercase character or number (offset: 0)',
`Bucket name must start and end with a lowercase character or number (offset: ${bucket.length - 1})`,
'Bucket name must not have dash next to period, or period next to dash, or consecutive periods (offset: 7)',
Expand Down