# Destroying Environments

## Overview

Uninstalling an environment triggers a destroy run that removes all infrastructure resources previously provisioned by that environment. Like a deploy run, the destroy run follows the plan-approve-apply lifecycle: Bluebricks generates a destroy plan for you to review before any resources are deleted.

{% hint style="info" icon="book" %}
For background on how runs work, see [Runs](https://bluebricks.co/docs/core-concepts/runs). For creating environments, see [Creating Environments](https://bluebricks.co/docs/core-concepts/environments/creating-environments).
{% endhint %}

## How to uninstall from the Bluebricks app

{% stepper %}
{% step %}

#### **Step 1: Open the environments page**

Navigate to **Environments** and find the environment you want to destroy.
{% endstep %}

{% step %}

#### **Step 2: Start the uninstall**

Click the three-dot menu on the environment row and select **Uninstall**.
{% endstep %}

{% step %}

#### **Step 3: Confirm**

A dialog asks you to confirm: "This will generate a plan to destroy the infrastructure resources previously provisioned by this environment. Are you sure you want to proceed?" Click **Uninstall** to continue.
{% endstep %}

{% step %}

#### **Step 4: Review the destroy plan**

Bluebricks generates a destroy plan and opens the run detail page. The plan shows all resources that will be removed. Review the changes carefully.
{% endstep %}

{% step %}

#### **Step 5: Approve and apply**

Click **Approve & Apply** to execute the destroy plan. The button appears in red for uninstall runs as a visual reminder.

{% hint style="warning" %}
Destroyed resources cannot be recovered. Back up any critical data before approving.
{% endhint %}
{% endstep %}
{% endstepper %}

## How to uninstall via the CLI

**Prerequisites**: Bricks CLI installed and authenticated. See [Bricks CLI](https://bluebricks.co/docs/bricks-cli/bricks-cli).

### Plan destruction first (recommended)

```bash
bricks uninstall --env-slug my-postgres-db --collection production --plan-only
```

Review the plan in the Bluebricks app, then approve to proceed.

### Uninstall by environment slug

```bash
bricks uninstall --env-slug my-postgres-db --collection production
```

### Uninstall by package name

```bash
bricks uninstall @myorg/postgres --collection production
```

If multiple environments exist for the same package, the CLI prompts you to select one.

### Key flags

<table><thead><tr><th width="193.328125">Flag</th><th>Description</th></tr></thead><tbody><tr><td><code>--env-slug</code></td><td>Environment slug to destroy</td></tr><tr><td><code>-c, --collection</code></td><td>Target collection</td></tr><tr><td><code>--plan-only</code></td><td>Generate a destroy plan without applying</td></tr></tbody></table>

For the full command reference, see [`bricks uninstall`](https://bluebricks.co/docs/bricks-cli/cli-reference/bricks_uninstall).

## What happens during uninstall

1. Bluebricks creates a destroy plan showing all resources to be removed
2. Resources are destroyed in reverse dependency order (child packages first)
3. The plan requires approval before execution, unless the environment is configured to auto-approve
4. Once complete, the environment moves to an uninstalled state

## Important considerations

* **Back up critical data** before destroying (databases, configuration files, logs)
* **Destroy child environments first** when environments depend on shared resources (e.g., destroy the app service before the VPC)
* **Check for resources outside Bluebricks management**: persistent storage volumes, external DNS records, and manually created firewall rules may require manual cleanup in your cloud console
* **Production collections**: if the collection has an [Owner Approval](https://bluebricks.co/docs/core-concepts/collections/owners-and-members) policy, a designated owner must approve the destroy plan

## See also

* [Runs](https://bluebricks.co/docs/core-concepts/runs): run lifecycle and plan/apply phases
* [Creating Environments](https://bluebricks.co/docs/core-concepts/environments/creating-environments): deploy blueprints into collections
* [Monitoring Runs](https://bluebricks.co/docs/core-concepts/runs/monitoring-runs): track run progress and status
