conn3x destroy
conn3x destroy removes every object the configuration manages. It’s the same as conn3x apply -destroy: it plans the removal, shows it, and asks you to confirm.
conn3x destroy [options]What Conn3x changes
Section titled “What Conn3x changes”Destroying a cloud resource deletes it, as in OpenTofu. Destroying a host step removes it from state, and what happens on the host depends on the step’s module and its on_remove setting:
"forget"leaves the host as it is. This is the default for files, packages, users and most settings, sodestroycan’t break a running server by surprise."delete"removes what the step made. This is the default for SSH keys, firewall rules, cron jobs and timers, so an old key or an open port isn’t left behind.
Each module’s page gives its default. To remove something from the hosts on destroy, set on_remove = "delete" in the step’s module block and apply that change before you run destroy. Conn3x uses the on_remove recorded in state.
When a circuit’s hosts are created in the same configuration, destroy removes the host steps before the servers they run on.
Like plan, destroy reads the cloud and the hosts first, unless you pass -refresh=false.
Options
Section titled “Options”destroy takes the options of apply. The ones used most:
| Option | Description |
|---|---|
-auto-approve |
Don’t ask for confirmation. |
-target=ADDRESS |
Destroy only this address and what depends on it. Repeat it for more. |
-var and -var-file |
Set input variables. |
-refresh=false |
Don’t read the cloud or the hosts first. |
-lock-timeout=DURATION |
How long to retry a state lock. |
To see the plan without destroying anything, run conn3x plan -destroy.
For the remaining options, see OpenTofu’s destroy page.
Examples
Section titled “Examples”Destroy everything, confirming at the prompt:
conn3x destroyStop managing one step on one host:
conn3x destroy -target='conn3x_file.web__page["web1"]'Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Destroyed, or nothing to destroy. |
| 1 | An error, or you didn’t confirm. |