From 56d01a0aaa55bc132aeedf4cc7359884d91c5f0e Mon Sep 17 00:00:00 2001 From: cktricky Date: Thu, 26 Apr 2018 11:46:05 -0400 Subject: [PATCH] this is printing much prettier than before --- libs/config.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/libs/config.py b/libs/config.py index c38963d..179de3c 100644 --- a/libs/config.py +++ b/libs/config.py @@ -26,7 +26,16 @@ def describe_configuration_recorders(region): client = boto3.client("config", region_name=region) response = client.describe_configuration_recorders() - print(response) + region_name = "Region: %s\n" % region + print(region_name) + print("=" * len(region_name)) + if not response['ConfigurationRecorders']: + print("No Rules Found") + else: + for r in response['ConfigurationRecorders']: + for k,v in r.items(): + print("%s: %s" % (k,v)) + print("\n") except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'InvalidClientTokenId': sys.exit("The AWS KEY IS INVALID. Exiting") @@ -54,7 +63,16 @@ def describe_configuration_rules(region): client = boto3.client("config", region_name=region) response = client.describe_config_rules() - print(response) + region_name = "Region: %s" % region + print(region_name) + print("=" * len(region_name)) + if not response['ConfigRules']: + print("No Rules Found") + else: + for r in response['ConfigRules']: + for k,v in r.items(): + print("%s: %s" % (k,v)) + print("\n") except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'InvalidClientTokenId': sys.exit("The AWS KEY IS INVALID. Exiting") @@ -75,8 +93,11 @@ def describe_configuration_rules(region): return response + def list_all_config_rules(): - describe_configuration_rules('us-east-1') + for region in regions: + describe_configuration_rules(region) def list_all_config_recorders(): - describe_configuration_recorders('us-east-1') + for region in regions: + describe_configuration_recorders(region)