Skip to content

Commit

Permalink
Added check for unused elastic load balancers
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dias committed Aug 28, 2019
1 parent a9f0dc7 commit 0532d62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ resource_stats.png
data/
private_commands/
output/
.vscode/
13 changes: 13 additions & 0 deletions shared/find_unused.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def find_unused_network_interfaces(region):

return unused_network_interfaces

def find_unused_elastic_load_balancers(region):
unused_elastic_load_balancers = []
elastic_load_balancers = query_aws(region.account, "elb-describe-load-balancers", region)
for elastic_load_balancer in pyjq.all(".LoadBalancerDescriptions[] | select(.Instances == [])", elastic_load_balancers):
unused_elastic_load_balancers.append({"LoadBalancerName": elastic_load_balancer["LoadBalancerName"]})

return unused_elastic_load_balancers


def add_if_exists(dictionary, key, value):
if value:
Expand Down Expand Up @@ -119,6 +127,11 @@ def find_unused_resources(accounts):
"network_interfaces",
find_unused_network_interfaces(region),
)
add_if_exists(
unused_resources_for_region,
"elastic_load_balancers",
find_unused_elastic_load_balancers(region),
)

unused_resources_for_account.append(
{
Expand Down

0 comments on commit 0532d62

Please sign in to comment.