SAM Doctor

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:

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

  1. Print the name the template actually produced — check the failed resource's properties in the stack events, not the source template.
  2. 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.
  3. Or omit BucketName entirely — 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