Skip to content

Instantly share code, notes, and snippets.

@z0ph
Last active May 29, 2019 09:49
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 z0ph/6f221e82d6dfc2f17dd6c3d9e8f342b4 to your computer and use it in GitHub Desktop.
Save z0ph/6f221e82d6dfc2f17dd6c3d9e8f342b4 to your computer and use it in GitHub Desktop.
Enable default EBS encryption on all regions #AWS - https://zoph.me (@z0ph)
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