library
turbot/aws_thrifty

Detect & correct EC2 classic load balancers if unused

Amazon EC2 classic load balancers with no instances attached still cost money and should be deleted. This query trigger identifies EC2 classic load balancers with no instances attached and either sends notifications or attempts predefined corrective actions.

Getting Started

By default, this trigger is disabled, but can be configured by setting the variables:

  • ec2_classic_load_balancers_if_unused_trigger_enabled should be set to true (default is false).
  • ec2_classic_load_balancers_if_unused_trigger_schedule should be set according to your desired running schedule.
  • ec2_classic_load_balancers_if_unused_default_action should be set to "notify" or any other desired action (e.g., "notify" for notifications or "delete_load_balancer" to delete the classic load balancers).

Then starting the server:

flowpipe server

or if you've set the variables in a .fpvars file:

flowpipe server --var-file=/path/to/your.fpvars

Query

select
concat(name, ' [', region, '/', account_id, ']') as title,
name,
region,
_ctx ->> 'connection_name' as cred
from
aws_ec2_classic_load_balancer
where
jsonb_array_length(instances) <= 0

Schedule

15m