atmos terraform state mv
Use this command to move an item in the Terraform state for an Atmos component in a stack.
Usage
Execute the terraform state mv command like this:
atmos terraform state mv <component> -s <stack> <source> <destination> [options]
This command moves a resource or module in the Terraform state from one address to another. This is useful for renaming resources or moving them between modules without destroying and recreating them.
State manipulation commands should be used carefully. Always back up your state before making changes.
Run atmos terraform state mv --help to see all the available options
Examples
# Rename a resource
atmos terraform state mv vpc -s dev aws_instance.web aws_instance.web_server
# Move a resource into a module
atmos terraform state mv vpc -s dev aws_instance.web module.web.aws_instance.main
# Move a module
atmos terraform state mv vpc -s dev module.old_name module.new_name
Arguments
component(required)Atmos terraform component.
source(required)The source address of the resource or module to move.
destination(required)The destination address for the resource or module.
Flags
--stack(alias-s) (required)Atmos stack.
--dry-run(optional)Show what would be executed without actually running the command.
atmos terraform state mv vpc -s dev --dry-run aws_instance.web aws_instance.web_server--skip-init(optional)Skip running
terraform initbefore executing the command.atmos terraform state mv vpc -s dev --skip-init aws_instance.web aws_instance.web_server
Native Terraform Flags
The atmos terraform state mv command supports native terraform state mv flags. Pass them directly or use -- to separate Atmos flags from Terraform flags.
-lock=trueLock the state file when locking is supported. Defaults to
true.atmos terraform state mv vpc -s dev -lock=false aws_instance.web aws_instance.web_server-lock-timeout=DURATIONDuration to retry a state lock. Defaults to
0s.atmos terraform state mv vpc -s dev -lock-timeout=30s aws_instance.web aws_instance.web_server-ignore-remote-versionIgnore remote state version constraints when performing the operation.
atmos terraform state mv vpc -s dev -ignore-remote-version aws_instance.web aws_instance.web_server
See Also
atmos terraform state- State management overviewatmos terraform state list- List resources in the stateatmos terraform state rm- Remove instances from the state