Skip to main content

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.

atmos terraform state --help

Usage​

Execute the terraform state command like this:

atmos terraform state <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.

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.

Examples​

List Resources in State​

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

Show Specific Resource​

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

Move Resource​

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

Remove Resource from State​

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

atmos terraform state vpc -s dev --skip-init
--dry-run (optional)

Show what would be executed without actually running the command.

atmos terraform state vpc -s dev --dry-run

Native Terraform Flags​

This command supports native terraform state flags such as Subcommands include list, show, mv, rm, pull, push, replace-provider. Use -state to specify state file path..