Skip to content

Instantly share code, notes, and snippets.

@tmichelet
Created January 5, 2016 23:24
Show Gist options
  • Save tmichelet/cece077611d8c996ff5f to your computer and use it in GitHub Desktop.
Save tmichelet/cece077611d8c996ff5f to your computer and use it in GitHub Desktop.
list ec2 instances for an access key
import boto
import boto.ec2
accounts = [
('<AWS_access_key_id>', '<AWS_secret_access_key>'),
]
REGIONS = ['us-east-1', 'us-west-2', 'us-west-1']
for key, secret in accounts:
for region in REGIONS:
print region
cec2 = boto.ec2.connect_to_region(region, aws_access_key_id=key, aws_secret_access_key=secret)
statuses = cec2.get_all_instance_status()
for status in statuses:
print status.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment