terraform-state-manager_skill

This skill helps you safely manage Terraform state by importing, moving, or removing resources while preserving stability.
  • TypeScript

181

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill first-fluke/fullstack-starter --skill terraform-state-manager

  • SKILL.md2.7 KB

Overview

This skill manages Terraform state operations such as importing existing resources, moving resources between addresses or modules, removing resources from state without destroying them, and migrating state backends. It provides step-by-step commands and safety guardrails to refactor state safely in production environments. Use it to fix state drift, migrate backends, or reorganize resource layouts without unintended downtime.

How this skill works

The skill describes the precise Terraform CLI commands and workflow for common state tasks: terraform import, terraform state mv, terraform state rm, and terraform init -migrate-state. It emphasizes pre- and post-operation verification steps like pulling a backup of the .tfstate file and running terraform plan to confirm no unexpected changes. It also covers handling state locks and safe unlock procedures with terraform force-unlock when appropriate.

When to use it

  • Import existing cloud resources that aren’t yet in Terraform state
  • Refactor resources by renaming or moving them into or out of modules
  • Remove resources from Terraform control while leaving the infrastructure intact
  • Migrate state storage from local files to remote backends such as GCS or S3
  • Recover from state corruption or stalled locks preventing Terraform runs

Best practices

  • Always create a state backup before any operation: terraform state pull > backup.tfstate
  • Perform operations one at a time and validate with terraform plan after each change
  • Ensure no one else is running Terraform; coordinate maintenance windows
  • Use versioned remote backends for production state and enable locking when supported
  • Document each state change in changelogs or runbooks to aid audits and rollbacks

Example use cases

  • Import an existing Cloud Storage bucket into Terraform to begin lifecycle management
  • Move a resource into a module after refactoring to keep addresses stable for other resources
  • Remove a manually managed VM from state while preserving the VM itself
  • Migrate state from a local file to a GCS backend during team onboarding
  • Force-unlock state after a CI crash to restore normal deployment workflows

FAQ

Pull and save a backup of the current state, update or add the matching resource block in your config, then run the CLI command and follow with terraform plan to verify no unintended changes.

Can I migrate state to a new backend without downtime?

Yes—update the backend configuration and run terraform init -migrate-state to copy state. Confirm the new backend and run terraform plan to ensure the migration succeeded.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational