Last active
May 29, 2019 09:49
-
-
Save z0ph/6f221e82d6dfc2f17dd6c3d9e8f342b4 to your computer and use it in GitHub Desktop.
Enable default EBS encryption on all regions #AWS - https://zoph.me (@z0ph)
This file contains hidden or 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
import boto3 | |
AWS_REGION = 'eu-west-1' | |
session = boto3.Session(region_name=AWS_REGION) | |
ec2 = session.client('ec2') | |
def main(event, context): | |
ec2_regions = [region['RegionName'] for region in ec2.describe_regions()['Regions']] | |
# For all AWS Regions | |
for region in ec2_regions: | |
conn = boto3.client('ec2', region_name=region) | |
print ("Checking AWS Region: " + region) | |
status = conn.get_ebs_encryption_by_default() | |
print ("===="*10) | |
result = status["EbsEncryptionByDefault"] | |
if result == True: | |
print ("Activated, nothing to do") | |
else: | |
print("Not activated, activation in progress") | |
conn.enable_ebs_encryption_by_default() | |
if __name__ == '__main__': | |
main(0,0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment