ERROR REFERENCE
InvalidBucketName (bucket name failed validation)
The BucketName in the template breaks S3's naming
rules, so creation is rejected before uniqueness is even checked.
Different failure from a taken name — this one is illegal, not
occupied.
WHAT IT MEANS
What this error means
The rules that trip people most:
- lowercase letters, numbers, dots, and hyphens only — no uppercase, no underscores;
- 3-63 characters, starting and ending with a letter or number;
- not formatted like an IP address.
In templates, the illegal name often is not typed anywhere - a
!Sub combining a stack name or parameter that carries
uppercase or underscores produces it at deploy time.
FIX
How to fix it
- Print the name the template actually produced — check the failed resource's properties in the stack events, not the source template.
- Fix the inputs to the substitution: lowercase the parameter values that feed bucket names, replace underscores with hyphens, and keep the total under 63 characters.
-
Or omit
BucketNameentirely — CloudFormation generates a compliant name and this whole class disappears.
AUTOMATE THE TRIAGE
Diagnose this automatically
SAM Doctor recognizes the validation wording (high confidence) and keeps it distinct from BucketAlreadyExists collisions. Runs locally; no AWS access, no log upload.
python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown
RELATED
Related errors
- BucketAlreadyExists / BucketAlreadyOwnedByYou — the legal-but-taken variant.
- S3 error: Access Denied (deployment bucket) — the artifact-bucket failure that often follows bucket churn.