terraform
resource_error
ai_generated
true
错误:资源实例已被孤立 - 它不再在配置中,但仍在状态中被跟踪
Error: Resource instance has been orphaned - it is no longer in the configuration but is tracked in state
ID: terraform/terraform-plan-with-orphan-resources
80%修复率
82%置信度
1证据数
2023-06-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Terraform v1.2+ | active | — | — | — |
根因分析
从 Terraform 配置中移除了一个资源,但其状态条目仍然存在,导致计划显示销毁。
English
A resource was removed from Terraform configuration but its state entry remains, causing plan to show destruction.
官方文档
https://developer.hashicorp.com/terraform/language/state/resource-behavior#orphaned-resources解决方案
-
运行 terraform state rm <资源地址> 从状态中移除孤立的资源而不销毁它
-
将资源重新添加到配置中并运行 terraform apply 以协调状态
无效尝试
常见但无效的做法:
-
90% 失败
Destroys the resource unintentionally; may cause data loss.
-
95% 失败
State file corruption risk; terraform state rm is safer.