terraform
resource_error
ai_generated
true
错误:加载状态失败:S3 存储桶 "my-terraform-state" 不存在
Error: Failed to load state: S3 bucket "my-terraform-state" does not exist
ID: terraform/s3-backend-bucket-not-found
90%修复率
87%置信度
1证据数
2024-03-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Terraform v1.5.0 | active | — | — | — |
| Terraform v1.6.0 | active | — | — | — |
| Terraform v1.7.0 | active | — | — | — |
根因分析
后端配置中指定的用于状态存储的S3存储桶尚未创建或已被删除。
English
The S3 bucket specified in the backend configuration for state storage has not been created or has been deleted.
官方文档
https://developer.hashicorp.com/terraform/language/settings/backends/s3解决方案
-
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'
无效尝试
常见但无效的做法:
-
Run 'terraform init' with -migrate-state flag
95% 失败
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% 失败
The new bucket also doesn't exist unless created manually.
-
Use local backend by removing the backend block
70% 失败
This changes the state location and may lose remote state history.