Skip to content

destroy

Permanently delete the AWS infrastructure created by apply when a project is retired or needs a clean rebuild, protecting you from ongoing AWS charges.

  • Verifies you are in a grada project (terraform/backend.tf must exist) and that the terraform binary is installed, exiting otherwise.
  • Asks for explicit confirmation before doing anything destructive; declining cancels with no changes. With --yes (or the global --headless flag), destruction proceeds without prompting.
  • Before destroying, wakes a stopped or transitional-state database back to available (RDS refuses to delete databases that aren’t available), so tearing down an asleep environment succeeds instead of failing mid-destroy; aborts with a retry message if the database never becomes ready.
  • Runs terraform destroy -auto-approve in terraform/, streaming progress, so all compute resources (ECS or Lambda, ALB or API Gateway, database, and related resources) are removed.
  • Parses the state bucket name and region out of terraform/backend.tf (region defaults to us-east-2 when not found), then optionally asks whether to also empty and delete the S3 state bucket via teardownStateBucket. Answering “No” keeps the bucket so apply can restore the infrastructure later. With --yes (or --headless), the bucket is deleted without asking.
  • Emits an infrastructure_destroyed telemetry event recording success and whether the state bucket was retained.
Terminal window
npx grada-run destroy
npx grada-run destroy --yes
Flag Description
--yes Answer “Yes” to both the destruction and state-bucket confirmations for non-interactive runs.
--headless Global automation flag; implies --yes for this command.