> For the complete documentation index, see [llms.txt](https://docs.onelens.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.onelens.cloud/automate/remediations/remediations-runbooks/runbook-catalog/delete-unused-ebs-volumes.md).

# Delete unused EBS Volumes

## What It Does

Deletes unused EBS volumes that are no longer attached to any EC2 instance. Unused volumes continue to incur storage costs even when idle. This runbook removes orphaned volumes after creating a snapshot for backup, helping reduce storage waste and control spend.

## Risk and Scope

| Detail                   | Value                     |
| ------------------------ | ------------------------- |
| **Risk Level**           | Medium                    |
| **AWS Service Targeted** | Elastic Block Store (EBS) |

{% hint style="warning" %}

## Permissions Required

Delete Permissions

* `ec2:DeleteVolume`

**Write Permissions**

* `ec2:CreateSnapshot`

**Read Permissions**

* `ec2:DescribeVolumes`

> These permissions are granted **only to the runbook**, not to the OneLens platform itself.
> {% endhint %}

## Optimization Policies Addressed

This runbook remediates violation tickets of the following policy:

| Policy ID | Policy Name                                                              |
| --------- | ------------------------------------------------------------------------ |
| ebs\_2    | EBS volumes should not be unattached                                     |
| ebs\_11   | EBS volumes should not be attached to stopped instances for long periods |

## Risk Mitigation

{% hint style="success" %}

## Risk Mitigation Strategy

* **Snapshots are** **taken** before the change to prevent any data loss.
* The volume can be **re-created** from that snapshot if needed.
  {% endhint %}

## How to Install

Refer to the [Runbook Setup Guide ](/automate/remediations/remediations-runbooks/install-runbooks.md#installing-a-runbook)for steps to install and enable this runbook in your environment.

## Runbook Workflow

### Step 1: Start

**Trigger:** Initiates the workflow to identify and delete orphaned EBS volumes.

### Step 2: validateEBS

**Action:**&#x52;uns a validation script to identify whether the EBS volume is unused and safe to delete.

### Step 3: If/Else

**Condition:** Checks whether the volume qualifies for deletion.

1. **If eligible, proceeds with deletion workflow:**
   1. **CreateSnapshot**\
      Creates a snapshot of the EBS volume to retain a backup.
   2. **WaitForSnapshotCompletion**\
      Ensures snapshot creation is complete by describing snapshot status.
   3. **DeleteVolume**\
      Deletes the EBS volume to eliminate unnecessary storage cost.
2. **Else:**

   Ends the workflow if no deletable volume is identified.

## See How It Works

<figure><img src="https://3963693991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiyNGpqVYfmDF6qt7Lzar%2Fuploads%2FOpmdkO8eUe1gyvuLUVWd%2FScreenshot%202025-05-13%20at%2013.35.57.png?alt=media&amp;token=4f1b4244-e2de-4f62-9dfb-ef3ed83caeff" alt=""><figcaption></figcaption></figure>

## Triggering the Runbook

To run this workflow:

### **1. Locate the Ticket**

Identify the ticket associated with the above mentioned policy violation.

### **2. Execute the Runbook**

Follow the steps described in the [executing a runbook](/automate/remediations/remediations-runbooks.md#executing-a-runbook) section to apply this runbook to the ticket.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.onelens.cloud/automate/remediations/remediations-runbooks/runbook-catalog/delete-unused-ebs-volumes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
