Created
January 5, 2016 23:24
list ec2 instances for an access key
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
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