Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Hardeep18/bcda89fcc62f21cfbeec03501a32f2b4 to your computer and use it in GitHub Desktop.
Save Hardeep18/bcda89fcc62f21cfbeec03501a32f2b4 to your computer and use it in GitHub Desktop.

Revisions

  1. @dagrz dagrz renamed this gist Oct 18, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @dagrz dagrz created this gist Oct 18, 2016.
    12 changes: 12 additions & 0 deletions gistfile1.txt
    Original 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']))