S3 backend bucket missing — cannot initialize state backend
Error: Unable to find matching value for tag
Focused incident mode — strips away everything but this runbook.
Symptoms
- Error: Unable to find matching value for tag
- S3 bucket does not exist: the bucket you are attempting to access must be addressed using the specified endpoint
- terraform init fails with bucket not found
If the S3 bucket and its state file are both gone, the infrastructure is unmanaged. You may need to import resources from scratch.
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Init error output
terraform init 2>&1 | tail -20Backend S3 bucket config
grep -A10 'backend "s3"' *.tf
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- aws s3api head-bucket returns 404
- terraform init fails with bucket not found
Confirm before fixing
aws s3api head-bucket --bucket <BUCKET> 2>&1Confirm the bucket does not exist
Fix
aws s3api create-bucket --bucket <BUCKET> --region <REGION>Recreate the bucket (state data is lost unless there is a backup)
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
aws s3api head-bucket --bucket <BUCKET> 2>&1Check if the bucket exists
aws s3api create-bucket --bucket <BUCKET> --region <REGION>Recreate the missing bucket
terraform init -migrate-stateRe-initialize the backend with the recreated bucket
Prevention
- Enable S3 versioning and delete protection on the state bucket.
- Enable S3 bucket replication or cross-region backup for state files.
- Use AWS Organizations SCPs to prevent accidental bucket deletion.
- Monitor S3 bucket deletion events with CloudTrail alerts.
Related runbooks
Same stack, same failure family — worth a skim.
Backend initialization required: please run "terraform init"
Error: Error loading state: SyntaxError: JSON input
terraform plan shows everything will be created (no existing resources in state)
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.