What problem does it solve?
When a Kubernetes cluster is recreated, Terraform state can become stale, referencing resources that no longer exist. This leads to terraform apply failures and resource conflicts, blocking infrastructure deployments. This Skill provides a systematic procedure to recover from such orphaned state issues.
Core Features & Use Cases
- Orphaned Resource Identification: Automatically lists Kubernetes and Helm resources in state that are no longer present in the cluster.
- Safe State Removal: Guides through
terraform state rm commands to clean up stale entries without affecting active infrastructure.
- Automated Recovery Script: Provides a Bash script to streamline the process of identifying and removing orphaned state.
- Prevention Strategies: Recommends using data sources, letting ArgoCD manage application resources, and remote state locking to prevent future issues.
- Use Case: If your
terraform apply fails with "Resource already exists in state" after a Rackspace Spot cloudspace was deleted and recreated, use this Skill to identify and remove the orphaned Kubernetes and Helm resources from your Terraform state, allowing you to successfully re-apply your infrastructure.
Quick Start
Use the terraform-state-recovery skill to identify and remove orphaned Kubernetes namespaces and Helm releases from the Terraform state after a cluster recreation. Explain how to verify the state is clean before re-applying.