ResourceNotFoundException
terraform
resource_error
ai_generated
true
错误:获取状态锁时出错:ResourceNotFoundException:请求的资源未找到
Error: Error acquiring the state lock: ResourceNotFoundException: Requested resource not found
ID: terraform/state-lock-dynamodb-table-not-found
92%修复率
87%置信度
1证据数
2023-07-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.3.0 | active | — | — | — |
| 1.4.0 | active | — | — | — |
| 1.5.0 | active | — | — | — |
根因分析
为状态锁定指定的 DynamoDB 表在 AWS 账户或区域中不存在,阻止了锁的获取。
English
The DynamoDB table specified for state locking does not exist in the AWS account or region, preventing lock acquisition.
官方文档
https://developer.hashicorp.com/terraform/language/settings/backends/s3#dynamodb-state-locking解决方案
-
使用 AWS CLI 手动创建 DynamoDB 表:aws dynamodb create-table --table-name terraform-lock --attribute-definitions AttributeName=LockID,AttributeType=S --key-schema AttributeName=LockID,KeyType=HASH --billing-mode PAY_PER_REQUEST
-
在单独的配置中使用 Terraform 创建 DynamoDB 表,然后迁移后端。
无效尝试
常见但无效的做法:
-
95% 失败
Running terraform init again does not create the DynamoDB table; it only configures the backend.
-
60% 失败
Setting the lock table to an empty string or removing it from the backend config causes Terraform to skip locking, but this can lead to state corruption.