Skip to main content

cleanup-aws-loadbalancers Infrastructure App

This infrastructure app cleans up AWS ALB/ELB load balancers with no instances attached to them.

Installation​

> app install cleanup-aws-loadbalancers
info

Upon installation, Fix Inventory will create a config fix.apps.cleanup_aws_loadbalancers.

The default minimum age threshold is 7 days. This means that if a load balancer is more than 7 days old and does not have any instances/backends attached, it will be flagged for cleanup.

The age threshold is configurable via the min_age config value.

Configuration​

  1. Execute the following command in Fix Inventory Shell to open the infrastructure app configuration for editing:

    > config edit fix.apps.cleanup_aws_loadbalancers
  2. Update the configuration with the desired minimum age:

    cleanup_aws_loadbalancers configuration
    min_age: '7 days'
    info

    Valid age units include:

    • weeks

    • days

    • hours

    • minutes

    Age units can be abbreviated to a single letter (e.g., 7d, 24h, 60m, etc.).

    A space in between the numeric value and the unit is also optional, meaning that 7d and 7 days are equivalent.

Usage​

Run the app using the app run command:

> app run cleanup-aws-loadbalancers
tip

Add the optional --dry-run flag to see what commands the app would perform, without actually executing them.

note

This infrastructure app 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.

Further Reading​