Skip to content

Instantly share code, notes, and snippets.

@ritxos
Forked from marshyski/boto-filter-tag.py
Created November 14, 2016 10:39
Show Gist options
  • Select an option

  • Save ritxos/5e2d7d8fa089968a5ebc898b0e104411 to your computer and use it in GitHub Desktop.

Select an option

Save ritxos/5e2d7d8fa089968a5ebc898b0e104411 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