Skip to content

Instantly share code, notes, and snippets.

@dagrz
dagrz / Retrieve all EC2 instance userData
Created October 18, 2016 02:18
Retrieve all EC2 instance userData
#!/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')