Moving Items in Terraform State

The mv subcommand

The terraform state mv command is used to move items in a Terraform state.


The mv subcommand has the following syntax: terraform state mv [options] SOURCE DESTINATION.


Within the options, there are a few important flags to highlight.

  • The dry-run flag can be thought of as a what-if. It tells us what it’ll do without making any changes.

  • The state flag is the path of the source state file, which needs to be specified if we’re not using the terraform.tfstate file or a remote back-end.

  • The state-out flag is the path of the destination file. Terraform uses the source state file unless this is specified.

Get hands-on with 1200+ tech skills courses.