atmos terraform destroy
Use this command to destroy Terraform-managed infrastructure for an Atmos component in a stack. This operation removes all resources managed by the component.
Usage
Execute the terraform destroy command like this:
atmos terraform destroy <component> -s <stack> [options]
This command creates a plan to destroy all resources managed by the given configuration and state, and then applies that plan.
Atmos enhances the destroy command with:
- Automatic
terraform initbefore destroying - Workspace selection and management
- Automatic variable file generation and passing
- Backend configuration
- Component validation and locking support
Configuration
Configure default behavior for terraform destroy in your atmos.yaml:
components:
terraform:
# Auto-generate backend configuration
auto_generate_backend_file: true
These settings can also be controlled via environment variables:
export ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE=true
Examples
Basic Destroy
# Destroy a component in a stack (will prompt for confirmation)
atmos terraform destroy vpc -s dev
Auto-Approve Destroy
# Destroy without confirmation prompt (use with caution!)
atmos terraform destroy vpc -s dev -auto-approve
Targeted Destroy
# Destroy specific resources only
atmos terraform destroy vpc -s dev -target=aws_instance.web
Graph-backed Bulk Destroy
Run destroys for multiple components through the Terraform dependency graph:
# Destroy every Terraform component, with dependents before dependencies
atmos terraform destroy --all -s dev
# Destroy only selected components
atmos terraform destroy --components eks/apps,eks/cluster,vpc -s dev
Destroy reverses the dependency graph so dependents are destroyed before the components they depend on. For example, an application component is destroyed before its cluster, and the cluster is destroyed before the VPC.
Independent destroy nodes can run concurrently when --max-concurrency is greater than 1. Concurrent destroy requires non-interactive approval with -auto-approve.
atmos terraform destroy --all -s dev --max-concurrency 2 -auto-approve
Use --failure-mode keep-going to continue independent graph branches after one component fails. The default is fail-fast.
Use --include-dependents to tear down a selection plus everything that depends on it, dependents first:
# Destroy the vpc components and everything that depends on them, dependents first
atmos terraform destroy --components=vpc -s dev --include-dependents
# Bound the expansion to direct dependents only
atmos terraform destroy --components=vpc -s dev --include-dependents=1
Using --include-dependencies with destroy also destroys the shared prerequisites of your selection — components that other, unselected components may still depend on. Atmos prints a warning when this flag is used with destroy. Prefer --include-dependents, which tears down the selection plus everything that depends on it, in safe dependents-first order.
Arguments
component(required)Atmos component name.
Flags
--stack/-s(required)Atmos stack name where the component is defined.
--skip-init(optional)Skip running
terraform initbefore executing the command.atmos terraform destroy vpc -s dev --skip-init--dry-run(optional)Show what would be executed without actually running the command.
atmos terraform destroy vpc -s dev --dry-run--log-order(optional)Controls how concurrent per-component logs are ordered when
--max-concurrencyis greater than1.Supported values:
stream(default) — print log lines as they arrive, interleaved across componentsgrouped— buffer each component's output and print it as a contiguous block after the component finishes
Environment variable:
ATMOS_TERRAFORM_DESTROY_LOG_ORDERatmos terraform destroy --all -s dev --max-concurrency 2 -auto-approve --log-order grouped--include-dependents(optional)With a multi-component selection (
--all,--components,--query,--stack,--tags,--labels,--affected), also destroy everything that depends on the selected components, dependents first. Accepts an optional depth: the bare flag expands the full dependent chain, while--include-dependents=1bounds it to direct dependents. Pass the depth with=; a space-separated value is not bound to the flag.atmos terraform destroy --components=vpc -s dev --include-dependentsEnvironment variable:
ATMOS_INCLUDE_DEPENDENTS--include-dependencies(optional)With a multi-component selection, also destroy the prerequisites of the selected components — even prerequisites in other stacks. Because prerequisites may be shared with components outside the selection, Atmos warns when this flag is used with destroy; prefer
--include-dependentsfor safe teardown. Accepts an optional depth (for example,--include-dependencies=1for direct dependencies only).atmos terraform destroy --components=eks/cluster -s dev --include-dependenciesEnvironment variable:
ATMOS_INCLUDE_DEPENDENCIES
Native Terraform Flags
-auto-approveSkip interactive approval before destroying.
atmos terraform destroy vpc -s dev -auto-approvewarningUse
-auto-approvewith extreme caution, especially in production environments.-target=RESOURCEDestroy only the specified resource. Can be used multiple times.
atmos terraform destroy vpc -s dev -target=aws_instance.web -target=aws_instance.db-parallelism=NLimit the number of concurrent operations (default: 10).
atmos terraform destroy vpc -s dev -parallelism=5
Related Commands
atmos terraform plan- Generate execution planatmos terraform apply- Apply changesatmos terraform init- Initialize working directory