diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/config/__init__.py @@ -0,0 +1 @@ + diff --git a/config/__init__.pyc b/config/__init__.pyc new file mode 100644 index 0000000..13ae580 Binary files /dev/null and b/config/__init__.pyc differ diff --git a/config/config.py b/config/config.py new file mode 100644 index 0000000..5aa8a4b --- /dev/null +++ b/config/config.py @@ -0,0 +1,33 @@ +''' +Config Library +''' + +import boto3 +import botocore +import pprint + +pp = pprint.PrettyPrinter(indent=5, width=80) + +#from http://docs.aws.amazon.com/general/latest/gr/rande.html +regions = ['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'ca-central-1', 'eu-central-1', 'eu-west-1', 'eu-west-2', 'ap-northeast-1', 'ap-northeast-2', 'ap-southeast-1', 'ap-southeast-2', ] + + +def describe_configuration_recorders(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, region): + response = [] + try: + client = boto3.client("config", aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY,region_name=region) + + response = client.describe_configuration_recorders() + except botocore.exceptions.ClientError as e: + if e.response['Error']['Code'] == 'InvalidClientTokenId': + sys.exit("The AWS KEY IS INVALID. Exiting") + elif e.response['Error']['Code'] == 'AccessDenied': + print('%s : does not have config access. Did you check first?' % AWS_ACCESS_KEY_ID) + pass + elif e.response['Error']['Code'] == 'AccessDeniedException': + print('%s : does not have config access. Did you check first?' % AWS_ACCESS_KEY_ID) + pass + else: + print "Unexpected error: %s" % e + + return response \ No newline at end of file diff --git a/config/config.pyc b/config/config.pyc new file mode 100644 index 0000000..f784030 Binary files /dev/null and b/config/config.pyc differ diff --git a/logging_list_monitoring_configuration.py b/logging_list_monitoring_configuration.py new file mode 100644 index 0000000..2d95f95 --- /dev/null +++ b/logging_list_monitoring_configuration.py @@ -0,0 +1,50 @@ +''' +list config and other logging info +port of https://gist.github.com/cktricky/f19e8d55ea5dcb1fdade6ede588c6576 +''' + +from config.config import * + +#from http://docs.aws.amazon.com/general/latest/gr/rande.html +regions = ['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'ca-central-1', 'eu-central-1', 'eu-west-1', 'eu-west-2', 'ap-northeast-1', 'ap-northeast-2', 'ap-southeast-1', 'ap-southeast-2', ] + + + + + + + + +def print_section_header_and_footer(text, end=False): + print("-" * 50) + print(text) + print("-" * 50) + + if end: + print("\n\n") + +def print_config_text(text): + print("#" * len(text)) + + +print_section_header_and_footer("BEGINNING OF CONFIG SERVICE REVIEW") + +for region in regions: + response = describe_configuration_recorders(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, region) + + config_service_text = "Config Service Recorders" + print_config_text(config_service_text) + print(config_service_text) + print("Region:" + region) + print_config_text(config_service_text) + + print response + print len(response['ConfigurationRecorders']) + + if len(response['ConfigurationRecorders']) <= 0: + print("NO CONFIGURATION DETECTED") + else: + for group in response['ConfigurationRecorders']: + pp.pprint(group['recordingGroup']) + +print_section_header_and_footer("END OF CONFIG SERVICE REVIEW", True) \ No newline at end of file