# 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:

```shell
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.

:::caution
State manipulation commands should be used carefully. Always back up your state before making changes.
:::

:::tip
Run `atmos terraform state mv --help` to see all the available options
:::

## Examples

```shell
# 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.
  ```shell
  atmos terraform state mv vpc -s dev --dry-run aws_instance.web aws_instance.web_server
  ```
- **`--skip-init` (optional)**

  Skip running `terraform init` before executing the command.
  ```shell
  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=true`**

  Lock the state file when locking is supported. Defaults to `true`.
  ```shell
  atmos terraform state mv vpc -s dev -lock=false aws_instance.web aws_instance.web_server
  ```
- **`-lock-timeout=DURATION`**

  Duration to retry a state lock. Defaults to `0s`.
  ```shell
  atmos terraform state mv vpc -s dev -lock-timeout=30s aws_instance.web aws_instance.web_server
  ```
- **`-ignore-remote-version`**

  Ignore remote state version constraints when performing the operation.
  ```shell
  atmos terraform state mv vpc -s dev -ignore-remote-version aws_instance.web aws_instance.web_server
  ```

## See Also

- [`atmos terraform state`](/cli/commands/terraform/state) - State management overview
- [`atmos terraform state list`](/cli/commands/terraform/state/list) - List resources in the state
- [`atmos terraform state rm`](/cli/commands/terraform/state/rm) - Remove instances from the state
