Forked from dagrz/Retrieve all EC2 instance userData
Last active
March 13, 2020 03:27
-
-
Save Hardeep18/bcda89fcc62f21cfbeec03501a32f2b4 to your computer and use it in GitHub Desktop.
Revisions
-
dagrz renamed this gist
Oct 18, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dagrz created this gist
Oct 18, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ #!/usr/bin/env python from __future__ import print_function import boto3 import base64 client = boto3.client(service_name='ec2', region_name='us-east-1') for region in client.describe_regions()['Regions']: ec2 = boto3.resource(service_name='ec2', region_name=region['RegionName']) for instance in ec2.instances.all(): response = instance.describe_attribute(Attribute='userData') if 'UserData' in response and response['UserData']: print(base64.b64decode(response['UserData']['Value']))