Skip to content

Instantly share code, notes, and snippets.

@mccabe615
Last active August 11, 2020 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mccabe615/e750021a9b714f04eb165f28102619f2 to your computer and use it in GitHub Desktop.
Save mccabe615/e750021a9b714f04eb165f28102619f2 to your computer and use it in GitHub Desktop.
import boto3, json
print("Account: ", end = '')
print(boto3.client('sts').get_caller_identity()['Account'])
client = boto3.client('config')
print()
print("Getting non-compliant config results")
print()
paginator = client.get_paginator('describe_compliance_by_config_rule')
page_iterator = paginator.paginate(ComplianceTypes=['NON_COMPLIANT'])
print('Config results (rule name: count):')
print()
for page in page_iterator:
#print(json.dumps(page))
for result in page['ComplianceByConfigRules']:
print(result['ConfigRuleName'] + ": ", end = '')
print(result['Compliance']['ComplianceContributorCount']['CappedCount'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment