Back to all patterns
AWS S3 Bucket Name Validation
Validation
Validates AWS S3 bucket names per AWS naming rules.
/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/How it works
S3 bucket names must be 3-63 characters, start and end with a lowercase letter or digit, and can contain lowercase letters, digits, hyphens, and dots.
Test Cases
Should Match
- my-bucket
- my.bucket.name
- bucket123
Should NOT Match
- My-Bucket
- a
- bucket_with_underscore
Quick Summary
Validates AWS S3 bucket names: 3-63 characters, lowercase letters, digits, hyphens, and dots. Must start and end with a letter or digit. Does not check for consecutive dots or IP-address format.
Key Takeaways
Key Takeaways
- 3-63 characters total
- Only lowercase letters, digits, hyphens, and dots
- Must start and end with a lowercase letter or digit
- Cannot contain consecutive dots (..) or be formatted as an IP address
Use Cases
When to use it
- Validating bucket name inputs in AWS infrastructure forms
- Checking bucket names in Terraform or CloudFormation templates
- CI/CD pipeline validation before creating S3 buckets
Watch out
Common Mistakes
- Using uppercase letters, S3 bucket names must be lowercase
- Using underscores, S3 does not allow underscores in bucket names
FAQ
AWS S3 Bucket Name Validation, Frequently Asked
Why must S3 bucket names be lowercase?
S3 bucket names are used in DNS hostnames for virtual-hosted-style URLs. DNS is case-insensitive and conventionally lowercase.
Are S3 bucket names globally unique?
Yes. S3 bucket names are globally unique across all AWS accounts and regions.