pulumi destroy: Usage, Options & Common CI Errors
Delete all resources in a stack - for ephemeral and preview environments.
pulumi destroy removes every resource a stack manages. It is the inverse of pulumi up and is most useful for tearing down PR preview stacks or ephemeral test environments in CI.
What it does
pulumi destroy deletes all resources tracked in the selected stack’s state, in dependency order. The stack itself and its config remain (use pulumi stack rm to remove those). In CI you pass --yes for an unattended teardown.
Common usage
# Destroy the selected stack (prompts)
pulumi destroy --stack acme/pr-123
# CI teardown: no prompt
pulumi destroy --stack acme/pr-123 --yes
# Destroy then remove the empty stack entirely
pulumi destroy --stack acme/pr-123 --yes
pulumi stack rm acme/pr-123 --yesCommon error in CI: resource protected from deletion
destroy fails with "error: refusing to delete protected resource ... To delete this resource, ... remove the protect flag". A resource was created with protect=true. Fix: clear protection first with pulumi state unprotect <urn> --yes (or remove protect in code and run pulumi up), then re-run destroy with --yes. For ephemeral PR stacks, avoid setting protect at all so automated cleanup never blocks.
Key options
| Option | Purpose |
|---|---|
| --yes / -y | Auto-approve (required in CI) |
| --stack NAME | Target stack to destroy |
| --skip-preview | Skip the preview step |
| --non-interactive | Never prompt |
| --exclude-protected | Skip protected resources |