# atmos terraform state

Use this command to manage the Terraform state for an Atmos component in a stack. Supports operations like list, move, pull, push, replace-provider, rm, and show.

## Usage

```shell
atmos terraform state <subcommand> <component> -s <stack> [options]
```

This command provides subcommands for advanced state management. These are useful for manipulating the Terraform state when necessary, though manual state manipulation should be done carefully.

:::info Atmos Behavior
Atmos provides standard setup for this command including automatic `terraform init` and workspace selection. Additionally, Atmos blocks state modifications if the component is locked (`metadata.locked: true`). The state operations themselves are handled by native Terraform.
:::

## Subcommands

## Examples

### List Resources in State

```shell
# List all resources in the state
atmos terraform state list vpc -s dev
```

### Show Specific Resource

```shell
# Show details of a specific resource
atmos terraform state show vpc -s dev aws_instance.web
```

### Move Resource

```shell
# Move a resource in the state
atmos terraform state mv vpc -s dev aws_instance.web aws_instance.web_server
```

### Remove Resource from State

```shell
# Remove a resource from state (doesn't destroy the actual resource)
atmos terraform state rm vpc -s dev aws_instance.web
```

## Arguments

- **`component` (required)**

  Atmos component name.

## Flags

- **`--stack` / `-s` (required)**

  Atmos stack name where the component is defined.
- **`--skip-init` (optional)**

  Skip running `terraform init` before executing the command.
  ```shell
  atmos terraform state vpc -s dev --skip-init
  ```
- **`--dry-run` (optional)**

  Show what would be executed without actually running the command.
  ```shell
  atmos terraform state vpc -s dev --dry-run
  ```

## Related Commands

- [`atmos terraform plan`](/cli/commands/terraform/plan) - Generate execution plan
- [`atmos terraform apply`](/cli/commands/terraform/apply) - Apply changes
- [`atmos terraform init`](/cli/commands/terraform/init) - Initialize working directory
