terraform
resource_error
ai_generated
true
Error: Failed to load state: S3 bucket "my-terraform-state" does not exist
ID: terraform/s3-backend-bucket-not-found
90%Fix Rate
87%Confidence
1Evidence
2024-03-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Terraform v1.5.0 | active | — | — | — |
| Terraform v1.6.0 | active | — | — | — |
| Terraform v1.7.0 | active | — | — | — |
Root Cause
The S3 bucket specified in the backend configuration for state storage has not been created or has been deleted.
generic中文
后端配置中指定的用于状态存储的S3存储桶尚未创建或已被删除。
Official Documentation
https://developer.hashicorp.com/terraform/language/settings/backends/s3Workarounds
-
95% success Create the S3 bucket manually with the correct name and region: `aws s3api create-bucket --bucket my-terraform-state --region us-east-1 --create-bucket-configuration LocationConstraint=us-east-1`
Create the S3 bucket manually with the correct name and region: `aws s3api create-bucket --bucket my-terraform-state --region us-east-1 --create-bucket-configuration LocationConstraint=us-east-1`
-
90% success Update the backend configuration to point to an existing bucket, then run 'terraform init -reconfigure'
Update the backend configuration to point to an existing bucket, then run 'terraform init -reconfigure'
中文步骤
Create the S3 bucket manually with the correct name and region: `aws s3api create-bucket --bucket my-terraform-state --region us-east-1 --create-bucket-configuration LocationConstraint=us-east-1`
Update the backend configuration to point to an existing bucket, then run 'terraform init -reconfigure'
Dead Ends
Common approaches that don't work:
-
Run 'terraform init' with -migrate-state flag
95% fail
The bucket still doesn't exist; migrate requires an existing bucket.
-
Change the bucket name in the backend block to a random new name
80% fail
The new bucket also doesn't exist unless created manually.
-
Use local backend by removing the backend block
70% fail
This changes the state location and may lose remote state history.