Moving Items in Terraform State
Learn how to move items in a Terraform state.
The mv
subcommand
The terraform state mv
command is used to move items in a Terraform state.
Syntax
The mv
subcommand has the following syntax: terraform state mv [options] SOURCE DESTINATION
.
Arguments
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 theterraform.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 1400+ tech skills courses.