Skip to content

Instantly share code, notes, and snippets.

@jritchey
Last active August 29, 2015 14:02
Show Gist options
  • Save jritchey/e47181f3a007ec24e89d to your computer and use it in GitHub Desktop.
Save jritchey/e47181f3a007ec24e89d to your computer and use it in GitHub Desktop.
How to find all running instances in a AWS region using Python and the Boto library
import boto.ec2
ec2_connection = boto.ec2.connect_to_region(region, aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
instances = ec2_connection.get_only_instances(filters={'instance-state-name': 'running'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment