terraform-state-operations

Back up Terraform state and enforce approval before state mv, rm, or import operations.

14|3|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/lgbarn/devops-skills --skill terraform-state-operations
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-state-operations
Source: https://github.com/lgbarn/devops-skills/tree/main/skills/terraform-state-operations
Command: npx skills add https://github.com/lgbarn/devops-skills --skill terraform-state-operations

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

State operations modify Terraform's understanding of infrastructure without changing actual resources. These operations can easily cause drift, orphan resources, or unintended recreations if not carefully managed.

Announce at start: "I'm using the terraform-state-operations skill for safe state surgery."

Core Features & Use Cases

  • Create a backup before any state operation (local or remote) to enable rollback.
  • Enforce an explicit approval workflow and maintain an operation record.
  • Provide safe state mv, state rm, and import workflows with verification steps and rollback planning.

Quick Start

Back up the Terraform state, obtain explicit approval, and verify a plan before performing any state move, remove, or import operation.

Frequently Asked Questions about terraform-state-operations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely move or remove resources in a Terraform state?

To safely perform Terraform state operations, you must create a state backup, obtain explicit approval, and verify a plan before executing state mv, state rm, or import workflows to prevent drift and orphaned resources.

What is the safest way to import existing infrastructure into Terraform state?

Safe Terraform state imports require generating a backup of the current state, securing explicit authorization, and running post-operation checks against a deterministic plan to ensure recovery procedures are in place.

Can I run Terraform state mv and state rm operations on remote backends?

Yes, Terraform state operations support both local and remote backends by enforcing backups, explicit approval workflows, and verification steps to maintain safety and enable rollback planning across your infrastructure.

Why do I need approval before modifying Terraform state?

Explicit approval is required before modifying Terraform state because these operations alter Terraform's understanding of infrastructure without changing actual resources, which can easily cause drift or unintended recreations if not carefully managed.

How do I rollback a Terraform state operation if something goes wrong?

You rollback a Terraform state operation by using the backup created before the operation began, allowing you to restore the previous state and recover from unintended drift or orphaned resources.

What is the best way to prevent orphaned resources during Terraform state surgery?

The best way to prevent orphaned resources during Terraform state surgery is to enforce backups, maintain an operation record, and execute verification steps with rollback planning before applying any state mv or state rm changes.