> 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/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/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:**&#x20;
   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="/files/kWm3MGdllrFfvYtdpshR" 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/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
