mirror of
https://github.com/RogerSik/aws-target-group-cleanup.git
synced 2024-11-24 00:30:28 +01:00
Add a counter for the number of groups we remove
This commit is contained in:
parent
68065e3982
commit
43a87b4d83
@ -25,6 +25,7 @@ def remove_target_group(arn, elb_client):
|
|||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
plugin_results = dict()
|
plugin_results = dict()
|
||||||
|
groups_removed_count = 0
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Remove ALB target groups not assigned to load balancers')
|
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')
|
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)
|
request_id = remove_target_group(target_group_arn, elb_client)
|
||||||
if request_id:
|
if request_id:
|
||||||
print("REMOVED (request id " + request_id + ")")
|
print("REMOVED (request id " + request_id + ")")
|
||||||
|
groups_removed_count += 1
|
||||||
else:
|
else:
|
||||||
print("ERROR")
|
print("ERROR")
|
||||||
sleep(0.3) # try not to over-run LB api throughput
|
sleep(0.3) # try not to over-run LB api throughput
|
||||||
else:
|
else:
|
||||||
print("DRYRUN,no deletion took place")
|
print("DRYRUN,no deletion took place")
|
||||||
|
|
||||||
print "Complete"
|
print "Complete. Removed " + str(groups_removed_count) + " orphaned target groups"
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
Loading…
Reference in New Issue
Block a user