This script automates the tedious process of migrating Terraform state when upgrading HashiCorp's Kubernetes Provider resources from deprecated versions (e.g., kubernetes_secret) to their stable _v1 counterparts (e.g., kubernetes_secret_v1).
It is specifically designed to handle "hundreds of resources" where terraform state mv fails due to schema incompatibility or sheer volume.
- Module Aware: Correctly handles deeply nested modules (e.g.,
module.app.module.db.kubernetes_secret.pass). - JSON Parsing: Uses
jqto parse Terraform state, avoiding regex fragility with HCL.