Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+22 more

    Terraform State Refactor Planner

    1

    Plan Terraform resource migrations and generate version-specific moved blocks to prevent accidental resource destruction.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Terraform State Refactor Planner

    Terraform State Refactor Planner

    Example session with this skill installed

    I need to move 'aws_instance.api_server' into a new module called 'compute'. I am running Terraform 1.5. Prepare the refactor plan and the HCL blocks.

    • Read your context and instructions
    • Compiled the terraform state refactor

    I have analyzed the resource move from the root module to the 'compute' module. Since you are using Terraform 1.5, we can use declarative moved blocks to handle this without manual state manipulation.

    Terraform Refactor Plan: api_server to module.compute

    ComponentDetail
    Refactor TypeSame-state Module Migration
    Source Addressaws_instance.api_server
    Target Addressmodule.compute.aws_instance.api_server
    TF Version1.5 (Supports moved blocks)
    StrategyDeclarative Refactor

    Proposed HCL Configuration

    Add the following block to your configuration (typically in a moved.tf file or at the root of the module where the resource currently resides):

    
    # Draft moved block for api_server migration
    moved {
      from = aws_instance.api_server
      to   = module.compute.aws_instance.api_server
    }
    

    Safety Checklist

    • Verification: Ensure the module "compute" block is already defined in your configuration.
    • [ ]

    Dry Run: Run terraform plan. The output should show "0 to add, 1 to change, 0 to destroy" with a specific note that the resource is being moved.

    • [ ]

    Clean up: After a successful apply in all environments, these blocks can be retained for history or removed once state is unified.

    Next steps

    1. Copy the moved block into your moved.tf file.
    2. Run a sanitized terraform plan and verify no "destroy" actions are scheduled for the API server.
    3. Share the plan output here if you want me to double-check the transition logic.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Refactoring Terraform resource names or module paths often results in unintended resource destruction and recreation. This read-only skill helps developers plan state migrations by mapping address changes and identifying the safest path forward based on your specific Terraform version. It bridges the gap between manual state mv commands and modern moved blocks.

    What it does

    • Address mapping creates a clear bridge between old resource addresses and their new destinations.
    • Refactor classification distinguishes between same-state moves and complex cross-state transfers.
    • Version-aware guidance provides specific strategy recommendations based on whether you use Terraform v1.1, v1.7, or older.
    • Sanitized plan review scans plan outputs to flag unexpected create, replace, or destroy actions before they hit production.
    • Snippet generation provides draft HCL blocks for moved, removed, or import statements.

    How it works

    1. Provide the current resource addresses and the target module or naming structure.
    2. Specify your Terraform version and whether the move stays within the same state file.
    3. Review the generated refactor strategy and draft HCL configuration blocks.
    4. Input a sanitized plan output to verify that Terraform interprets your changes as moves rather than destructions.

    Frameworks & tools

    This skill is designed for Terraform HCL and CLI workflows. It supports logic for moved blocks (v1.1+), removed blocks (v1.7+), and standard state mv operations.

    Why this beats prompting it yourself

    Generic AI often suggests state mv by default, which can be dangerous in CI/CD pipelines or shared remote states. This skill enforces a "preflight" checklist that accounts for version-specific features like moved blocks, ensuring your refactor is declarative and auditable.

    Use cases

    • Renaming existing resources to follow new organizational naming conventions.
    • Moving monolithic resources into reusable sub-modules.
    • Migrating resources between different state files using removed and import blocks.
    • Refactoring count instances into for_each maps while preserving state.

    Known limitations

    This tool is for planning only and does not execute Terraform commands or mutate state files. It does not support OpenTofu. Requires manual sanitization of plan outputs before sharing.

    How to use

    Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scanned

    Verified clean 16 days ago

    • Passed all security checks, Safe to install

    Requires

    Hashicorp
    Agensi

    Listed16 days ago

    What's inside

    Frequently Asked Questions