# Delete idle Classic/Application Load Balancers

## What It Does

Deletes idle Elastic Load Balancers (ELBs), including Classic that are not actively handling traffic. Unused load balancers may incur hourly charges and contribute to unnecessary cloud cost. Deleting them improves infrastructure hygiene and optimizes spend.

## Risk and Scope

| Detail                   | Value                  |
| ------------------------ | ---------------------- |
| **Risk Level**           | Low                    |
| **AWS Service Targeted** | Elastic Load Balancing |

{% hint style="warning" %}

## Permissions Required

**Delete Permissions**

* `elasticloadbalancing:DeleteLoadBalancer`
* `elasticloadbalancing:DeleteTargetGroup`
* `elasticloadbalancing:DeleteLoadBalancerListeners`
* `elasticloadbalancing:DeleteListeners`

**Read Permissions**

* `elasticloadbalancing:DescribeLoadBalancers`

> 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                                                                   |
| --------- | ----------------------------------------------------------------------------- |
| elb\_1    | Application Load Balancers should not have zero requests for extended periods |

## Risk Mitigation

{% hint style="success" %}

## Risk Mitigation Strategy

* The change is assessed as **low risk** with limited scope and impact.
* **No downtime** is expected during or after implementation.
* **No additional safety measures** are required due to the non-disruptive nature of the change.
* A **rollback plan is not defined**, as standard procedures are sufficient to manage the change.
  {% 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**: Begins the runbook to identify and delete idle Classic, Application, Network, or Gateway load balancers.

### Step 2: CheckIfLBIsIdleAndClassic

**Action:** Executes a script to determine whether each load balancer is idle and whether it is of Classic or newer type (v2).

### Step 3: If/Else

**Condition:** Checks if the load balancer meets the deletion criteria.

1. **If eligible LB is idle:**
   1. **DeleteLoadBalancer**\
      Executes `DeleteLoadBalancer` for ELBv2 load balancers.
   2. **DeleteLoadBalancer\_Classic**\
      Executes `DeleteLoadBalancer` for Classic load balancers.
2. **Else:**

   Workflow ends if no deletable load balancer is found.

## See How It Works

<figure><img src="/files/wp2Y2nqxpafi0AgOWLX6" 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: 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:

```
GET https://docs.onelens.cloud/automate/remediations/runbooks/runbook-catalog/delete-idle-classic-application-load-balancers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
