Skip to main content

atmos terraform state rm

Use this command to remove instances from the Terraform state for an Atmos component in a stack.

atmos terraform state rm --help

Usage

Execute the terraform state rm command like this:

atmos terraform state rm <component> -s <stack> <address> [options]

This command removes a resource instance from the Terraform state. The actual infrastructure resource is not destroyed — it is simply no longer managed by Terraform. This is useful for importing resources into a different state or removing resources that were created outside of Terraform.

caution

After removing a resource from state, Terraform will no longer manage it. Use this command carefully.

tip

Run atmos terraform state rm --help to see all the available options

Examples

# Remove a single resource
atmos terraform state rm vpc -s dev aws_instance.web

# Remove a module
atmos terraform state rm vpc -s dev module.web

# Remove a resource from a module
atmos terraform state rm vpc -s dev module.web.aws_instance.main

Arguments

component (required)

Atmos terraform component.

address (required)

The address of the resource instance to remove from the state.

Flags

--stack (alias -s) (required)

Atmos stack.

--dry-run (optional)

Show what would be executed without actually running the command.

atmos terraform state rm vpc -s dev --dry-run aws_instance.web
--skip-init (optional)

Skip running terraform init before executing the command.

atmos terraform state rm vpc -s dev --skip-init aws_instance.web

Native Terraform Flags

The atmos terraform state rm command supports native terraform state rm 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.

atmos terraform state rm vpc -s dev -lock=false aws_instance.web
-lock-timeout=DURATION

Duration to retry a state lock. Defaults to 0s.

atmos terraform state rm vpc -s dev -lock-timeout=30s aws_instance.web
-ignore-remote-version

Ignore remote state version constraints when performing the operation.

atmos terraform state rm vpc -s dev -ignore-remote-version aws_instance.web

See Also