From 43a87b4d83ca3211e328f958e43e904a3f5f3c18 Mon Sep 17 00:00:00 2001 From: Dave North Date: Tue, 25 Sep 2018 11:11:30 -0400 Subject: [PATCH] Add a counter for the number of groups we remove --- src/aws-target-group-cleanup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/aws-target-group-cleanup.py b/src/aws-target-group-cleanup.py index d44350d..43f9f4c 100644 --- a/src/aws-target-group-cleanup.py +++ b/src/aws-target-group-cleanup.py @@ -25,6 +25,7 @@ def remove_target_group(arn, elb_client): def main(argv): plugin_results = dict() + groups_removed_count = 0 parser = argparse.ArgumentParser(description='Remove ALB target groups not assigned to load balancers') parser.add_argument('-f','--force', help='Perform the actual deletes (will run in dryrun mode by default)', action='store_true') @@ -69,13 +70,14 @@ def main(argv): request_id = remove_target_group(target_group_arn, elb_client) if request_id: print("REMOVED (request id " + request_id + ")") + groups_removed_count += 1 else: print("ERROR") sleep(0.3) # try not to over-run LB api throughput else: print("DRYRUN,no deletion took place") - print "Complete" + print "Complete. Removed " + str(groups_removed_count) + " orphaned target groups" if __name__ == "__main__": main(sys.argv[1:])