Last active
February 12, 2019 17:46
-
-
Save rkreddyp/c9f54a3252dbf2143ecdb117ae3a5f29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Check Cloudtrail Configuration Across All Regions | |
region_arr = aws_helpers.get_region_array() | |
df_arr = [] | |
for region in region_arr: | |
cclient=boto3.client('cloudtrail',region_name=region) | |
cdf = pd.DataFrame(cclient.describe_trails()['trailList']) | |
cdf = cdf [[ 'Name', 'S3BucketName', 'IsMultiRegionTrail']] | |
df_arr.append(cdf) | |
ctedf = pd.concat(df_arr) | |
display(HTML(ctedf.drop_duplicates().to_html(index=False))) | |
### Check Whether GuardDuty is Enabled Across All Regions | |
region_arr = aws_helpers.get_region_array() | |
df_arr = [] | |
for region in region_arr: | |
gdf = pd.DataFrame() | |
try : | |
gdclient = boto3.client('guardduty',region_name=region) | |
if len (gdclient.list_detectors()['DetectorIds']) > 0 : | |
gdf = pd.DataFrame(gdclient.list_detectors()['DetectorIds'], columns=['DetectorIds']) | |
gdf['region']=region | |
else : | |
gdf['DetectorIds'] = "NA" | |
gdf['region']=region | |
df_arr.append(gdf) | |
except : | |
pass | |
gdconcatdf = pd.concat(df_arr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment