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