Table of content (Full doc in ReadTheDocs) :
Is a wrapper tool of Boto3 library to list inventory and manage your AWS infrastructure The objective of the wrapper is to abstract the use of AWS, being able to dig through all the data of our account, and for example you will be able of:
- Run a ssh-command for all instances in all regions
- List all instances with exposed critical ports like 22 or 3389
- Get info about all certificates of your account/s
- Obtain all the infrastructure after a domain associated with a balancer
pip install awspice
The client is built and configured using awspice.connect()
. This method indicates the type of authentication and region on which you are going to work.
import awspice
aws = awspice.connect() # Region: eu-west-1 | Profile: Default
aws = awspice.connect(region='us-west-2', profile='dev_profile')
aws = awspice.connect('us-west-2', access_key='AKIA***********', secret_key='/HR$4************')
Example: Get balancer and instances behind a domain.
aws = awspice.connect()
elb = aws.service.elb.get_loadbalancer_by('domain', 'choosetravel.es')
for elb_instance in elb['Instances']:
instance = aws.service.ec2.get_instance_by('id', elb_instance['InstanceId'])
Example: List all unused volumes
regions = aws.service.ec2.get_regions()
volumes = awsmanager.service.ec2.get_volumes_by('status', 'available', regions=regions)
Example: Search instance in all accounts and regions by Public IP
profiles = aws.service.ec2.get_profiles()
regions = aws.service.ec2.get_regions()
for profile in profiles:
aws.service.ec2.change_profile(profile)
instance = aws.service.ec2.get_instance_by('publicip', '35.158.163.235', regions=regions)
if instance:
print 'Instance found: %s (Account: %s, Region: %s)' % (instance['InstanceId'], instance['RegionName'], instance['Authorization']['Value'])
break