From 036f2b3a411b2f6a2d330dcfe97fa126c17816fd Mon Sep 17 00:00:00 2001 From: c0decave Date: Mon, 16 Dec 2019 15:59:31 +0100 Subject: [PATCH] show regions --- count_resources.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/count_resources.py b/count_resources.py index b0214dd..788a3bc 100644 --- a/count_resources.py +++ b/count_resources.py @@ -15,7 +15,8 @@ resource_totals = {} @click.option('--secret', help='AWS Secret Key') @click.option('--profile', help='If you have multiple credential profiles, use this option to specify one.') @click.option('--cregion', help='Choose the region to test for (example: us-east-1, us-west-1), you can provide comma seperated list, like so: us-east-1,me-south-1,us-west-2') -def controller(access, secret, profile, cregion): +@click.option('--show-regions', help='Show available regions',default=False,is_flag=True) +def controller(access, secret, profile, cregion,show_regions): global session global args args = {'region':None} @@ -60,6 +61,13 @@ def controller(access, secret, profile, cregion): # Then build out the master list of regions to then fill in the service counts # Also build a separate dictionary for cross-region totals + if show_regions: + print('Available regions:') + region_list = session.get_available_regions('ec2') + for region in region_list: + print(region) + sys.exit(0) + if args['region'] != None: if cregion.find(',') != -1: res = cregion.split(',')