@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
mdx 74 lines 3.04 KB
Raw
1 ---
2 title: destroy
3 description: Delete every resource in a stack — plan all existing resources for deletion, ask for approval, and remove them in dependency order.
4 ---
5
6 import Terminal from "../../../components/Terminal.astro";
7
8 ```sh
9 alchemy destroy [options]
10 ```
11
12 `destroy` deletes every resource in a stack. It computes a plan where all existing resources are marked for deletion, asks for approval, and removes them in dependency order.
13
14 Under the hood, `destroy` is `deploy` with the desired state zeroed out — every resource in state plans as a deletion.
15
16 <Terminal content={`[u]Plan[/u]: [r]2 to delete[/r]
17
18 [r]-[/r] [b]Worker[/b] [d](Cloudflare.Worker)[/d]
19 [r]-[/r] [b]Bucket[/b] [d](Cloudflare.R2.Bucket)[/d]
20
21 Proceed?
22 ◉ Yes ○ No
23 [r]✗[/r] [b]Worker[/b] [d](Cloudflare.Worker)[/d] [r]deleted[/r]
24 [r]✗[/r] [b]Bucket[/b] [d](Cloudflare.R2.Bucket)[/d] [r]deleted[/r]`} />
25
26 ## Flags
27
28 | Option | Description |
29 | ------------------- | ----------------------------------------------------------------- |
30 | `--config, -c <file>` | Stack file to destroy (defaults to `alchemy.run.ts`) |
31 | `--stage <name>` | Stage to destroy (defaults to `$ALCHEMY_STAGE` or `live_$USER`) |
32 | `--yes` | Skip the approval prompt |
33 | `--dry-run` | Show what would be deleted without actually deleting |
34 | `--profile <name>` | Auth profile to use (defaults to `$ALCHEMY_PROFILE` or `default`) |
35 | `--env-file <path>` | Load environment variables from a file |
36
37 ## Examples
38
39 ```sh
40 # Destroy a PR preview environment
41 alchemy destroy --stage pr-42 --yes
42
43 # Destroy your personal cloud sandbox
44 alchemy destroy --stage live_sam
45
46 # Destroy the local-dev stage created by alchemy dev
47 alchemy destroy --stage dev_sam
48 ```
49
50 ## Retained resources
51
52 Resources declared with `RemovalPolicy.retain()` are skipped by
53 `destroy`: the provider's `delete` is never called and only the state
54 row is dropped, so the cloud object outlives the stack. The same is
55 true of a resource whose declaration you simply delete — the orphan
56 sweep reads the policy from the state row, not from your code.
57
58 ```typescript
59 import * as RemovalPolicy from "alchemy/RemovalPolicy";
60
61 const data = yield* R2.Bucket("Data").pipe(RemovalPolicy.retain());
62 ```
63
64 See [Resource lifecycle › Removal policy](/infrastructure-as-code/resource-lifecycle#removal-policy).
65
66 `destroy` is scoped to one stack + stage and driven by the state store; to enumerate and delete everything a set of providers can see in the live account, see [nuke](/cli/nuke).
67
68 ## Where next
69
70 - [deploy](/cli/deploy) — bring the stack back
71 - [nuke](/cli/nuke) — account-wide teardown, not scoped to a stack
72 - [state](/cli/state) — inspect and clear the state the plan is driven by
73 - [Stages](/environments/stages) — how environments are isolated
74 - [Resource lifecycle › Removal policy](/infrastructure-as-code/resource-lifecycle#removal-policy) — keep a resource when its stack goes away