ec2

Query for EC2 instances simply
Download

ec2 Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Matt Robenolt
  • Publisher web site:
  • https://github.com/mattrobenolt/

ec2 Tags


ec2 Description

ec2 is a light weight wrapper around boto to query for AWS EC2 instances in a sane way.Amazon EC2Ever try to query for some instances with boto? It sucks.>>> import ec2>>> ec2.instances.filter(state='running', name__startswith='production')Install pip install ec2UsageAWS credentialsCredentials are defined as a global state, either through an environment variable, or in Python.ec2.credentials.ACCESS_KEY_ID = 'xxx'ec2.credentials.SECRET_ACCESS_KEY = 'xxx'QueryingAll instancesec2.instances.all()FilteringFilter style is based on Django's ORM All filters map directly to instance properties.ec2.instances.filter(id='i-xxx') # Exact instance idec2.instances.filter(state='running') # Exact instance stateFilters will also dig into tags.ec2.instances.filter(name='production-web') # Exact "Name" tagFilters support many types of comparisons, similar to Django's ORM filters.ec2.instances.filter(name__exact='production-web-01') # idential to `name='...'`ec2.instances.filter(name__iexact='PRODUCTION-WEB-01') # Case insensitive "exact"ec2.instances.filter(name__like=r'^production-web-\d+$') # Match against a regular expressionec2.instances.filter(name__ilike=r'^production-web-\d+$') # Case insensitive "like"ec2.instances.filter(name__contains='web') # Field contains the search stringec2.instances.filter(name__icontains='WEB') # Case insensitive "contains"ec2.instances.filter(name__startswith='production') # Fields starts with the search stringec2.instances.filter(name__istartswith='PRODUCTION') # Case insensitive "startswith"ec2.instances.filter(name__endswith='01') # Fields ends with the search stringec2.instances.filter(name__iendswith='01') # Case insensitive "endswith"Filters can also be chained.ec2.instances.filter(state='running', name__startswith='production')Search fields- id (Instance id)- state (running, terminated, pending, shutting-down, stopping, stopped)- public_dns_name- ip_address- private_dns_name- private_ip_address- root_device_type (ebs, instance-store)- key_name (name of the SSH key used on the instance)- image_id (Id of the AMI)All fields can be found at: https://github.com/boto/boto/blob/d91ed8/boto/ec2/instance.py#L157-204ExampleGet public ip addresses from all running instances who are named production-web-{number}import ec2ec2.credentials.ACCESS_KEY_ID = 'xxx'ec2.credentials.SECRET_ACCESS_KEY = 'xxx'for instance in ec2.instances.filter(state='running', name__like=r'^production-web-\d+$'): print instance.ip_addressProduct's homepage


ec2 Related Software