DELAPARRA
Index
Color
NL
Category: Terraform

state mv / rm

Explained by Updated

What is state mv / rm?

state mv / rm: Surgically move a resource’s address (after a refactor) or remove it from state without destroying the real resource. terraform state mv and terraform state rm change Terraform's records without touching real infrastructure. state mv gives a resource a new address, for example after renaming it or moving it into a module. state rm makes Terraform forget a resource, while it keeps existing in the cloud.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about state mv / rm

How is state mv / rm used in practice?

Without state mv, a rename looks to Terraform like deleting one resource and creating another, which could destroy and recreate a database.

What should you keep in mind with state mv / rm?

Newer Terraform versions offer moved and removed blocks in configuration that do the same thing. They are usually better, because the change is reviewed in a pull request and applied consistently in every environment. Whichever you use, back up the state first and run a plan afterwards to confirm nothing unexpected will be destroyed.

What does an example of state mv / rm look like?

terraform state mv aws_s3_bucket.old aws_s3_bucket.new terraform state rm aws_s3_bucket.logs

At a glance

CategoryTerraform
Explained by
Updated

More Terraform terms

All terms starting with S

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.