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%Fix Rate
82%Confidence
1Evidence
2023-06-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Terraform v1.2+ | active | — | — | — |
Root Cause
A resource was removed from Terraform configuration but its state entry remains, causing plan to show destruction.
generic中文
从 Terraform 配置中移除了一个资源,但其状态条目仍然存在,导致计划显示销毁。
Official Documentation
https://developer.hashicorp.com/terraform/language/state/resource-behavior#orphaned-resourcesWorkarounds
-
95% success Run terraform state rm <resource_address> to remove the orphaned resource from state without destroying it
Run terraform state rm <resource_address> to remove the orphaned resource from state without destroying it
-
85% success Add the resource back to configuration and run terraform apply to reconcile state
Add the resource back to configuration and run terraform apply to reconcile state
中文步骤
运行 terraform state rm <资源地址> 从状态中移除孤立的资源而不销毁它
将资源重新添加到配置中并运行 terraform apply 以协调状态
Dead Ends
Common approaches that don't work:
-
90% fail
Destroys the resource unintentionally; may cause data loss.
-
95% fail
State file corruption risk; terraform state rm is safer.