Skip to content

Instantly share code, notes, and snippets.

@nmagee
Created October 1, 2020 17:09
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 nmagee/b4eb58591409f1408b5bc980c67f1267 to your computer and use it in GitHub Desktop.
Save nmagee/b4eb58591409f1408b5bc980c67f1267 to your computer and use it in GitHub Desktop.
Python3 snippet to iterate out InstanceIds in EC2.
import boto3
ec2 = boto3.client('ec2')
response = ec2.describe_instances()
for r in response['Reservations']:
for i in r['Instances']:
print(i['InstanceId'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment