Identifiers
AWS S3 Bucket Name
Validate AWS S3 bucket names per the standard naming rules: 3–63 chars, lowercase, alphanumeric + dots + hyphens.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
^[a-z0-9](?:[a-z0-9.\-]{1,61}[a-z0-9])?$Raw source: ^[a-z0-9](?:[a-z0-9.\-]{1,61}[a-z0-9])?$
How it works
First and last char must be lowercase alphanumeric. Middle can contain dots and hyphens too. Length is 3–63 chars total. This is the STRUCTURAL rule — S3 also forbids names that look like IPs and a few other edge cases the regex doesn't catch.
Examples
Input
my-app-uploadsMatches
my-app-uploads
Input
logs.example.comMatches
logs.example.com
Input
Invalid_NameNo match
—Common use cases
- •Terraform / CloudFormation validation
- •S3 bucket auto-provisioning workflows
- •Multi-tenant naming convention enforcement
- •Migration tooling between regions / accounts
Related patterns
Kubernetes Pod Name (RFC 1123)
IdentifiersValidate Kubernetes pod names per the RFC 1123 DNS label rules — lowercase, ≤63 chars, no leading/trailing hyphen.
Python Package Name (PEP 508)
IdentifiersValidate Python distribution package names per PEP 508: letters, digits, dots, underscores, hyphens.
AWS ARN (Amazon Resource Name)
IdentifiersMatch AWS ARNs (Amazon Resource Names) across commercial, China, and GovCloud partitions.
npm Package Name
IdentifiersValidate npm package names including scoped packages (@org/package), per the npm naming spec.