Forked from dagrz/Retrieve all EC2 instance userData
Created
September 25, 2019 09:06
-
-
Save nohupped/a292058c0783eec4f965637e9438e67d to your computer and use it in GitHub Desktop.
Retrieve all EC2 instance userData
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
#!/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'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment