Skip to content

Instantly share code, notes, and snippets.

@marshyski
Last active June 14, 2017 23:46
Show Gist options
  • Save marshyski/b8d47557d241298c72e7 to your computer and use it in GitHub Desktop.
Save marshyski/b8d47557d241298c72e7 to your computer and use it in GitHub Desktop.
Filter instances by a tag and get private IP address
reservations = ec2.get_all_instances(filters={"tag:Purpose": "Web"})
for res in reservations:
for inst in res.instances:
if inst.private_ip_address:
if inst.state == 'running':
print inst.private_ip_address
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment