Skip to main content
Version: 2.4.7

How to Clean Up AWS Load Balancers

When compute instances are removed, their load balancers are sometimes left behind.

Resoto's cleanup_aws_loadbalancers plugin can find and delete these orphaned load balancers.

Prerequisites

This guide assumes that you have already installed and configured Resoto to collect your cloud resources.

Directions

  1. Execute the following command in Resoto Shell to open the Resoto Worker configuration for editing:

    > config edit resoto.worker
  2. Enable cleanup by modifying the resotoworker section of the configuration as follows:

    resotoworker:
    # Enable cleanup of resources
    cleanup: true
    # Do not actually cleanup resources, just create log messages
    cleanup_dry_run: false
    # How many cleanup threads to run in parallel
    cleanup_pool_size: 16

    When cleanup is enabled, marked resources will be deleted as a part of the collect_and_cleanup workflow, which runs each hour by default.

    tip

    Set cleanup_dry_run to true to simulate cleanup without actually deleting resources.

  3. Update the plugin_cleanup_aws_loadbalancers section, setting the enabled property to true:

    cleanup_aws_loadbalancers plugin configuration
    plugin_cleanup_aws_loadbalancers:
    # Enable plugin?
    enabled: true
    # Minimum age of unused load balancers to cleanup
    min_age: 7d
    note

    The above plugin configuration cleans up ELBs, ALBs, and ALB target groups older than the minimum age with no attached backends. Items tagged with expiration: never will not be flagged for cleanup.

The plugin will now run each time Resoto emits the post_cleanup_plan event. The post_cleanup_plan event is a part of the collect_and_cleanup workflow and emitted after resource planning is complete but before the cleanup is performed.

Each time the cleanup_aws_loadbalancers plugin runs, orphaned load balancers will be flagged for removal during the next cleanup run.

Further Reading