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.
What it does
Section titled “What it does”- Verifies you are in a grada project (
terraform/backend.tfmust exist) and that theterraformbinary is installed, exiting otherwise. - Asks for explicit confirmation before doing anything destructive; declining cancels with no changes. With
--yes(or the global--headlessflag), 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-approveinterraform/, 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 tous-east-2when not found), then optionally asks whether to also empty and delete the S3 state bucket viateardownStateBucket. Answering “No” keeps the bucket soapplycan restore the infrastructure later. With--yes(or--headless), the bucket is deleted without asking. - Emits an
infrastructure_destroyedtelemetry event recording success and whether the state bucket was retained.
npx grada-run destroynpx 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. |
See also
Section titled “See also”- apply
- doctor
- sleep & wake (pause billing temporarily instead of tearing down)