By this time you may realize who important is cloud computing. To become cloud expert as a system administrator we should know some programming to automate cloud instances creation. When we say cloud the first thing comes to our mind is Amazon AWS cloud. There is a funny and interesting point how AWS cloud all started in 2006. In this post we will see how to install and configure boto module of python which acts as an API(Application program interface).
Installing Python boto in Linux
Step 1: Install python, python-dev, python-pip applications if they are not installed as these packages are required for boto instalation
Installing boto on Redhat based machines(Centos/Fedora):
yum install -y python python-dev python-pip
Installing boto on Debian based machines(Ubuntu):
apt-get install -y python python-dev python-pip
Step2: Once the above packages are installed, install boto by using pip which is a python module installer
pip install boto
Configuring Python boto in Linux
As boto is an API tool, we have to configure it to access AWS or openstack as a user. So we have to specify AWS user credentials in a boto understandable way. In order to access AWS through boto we should have AWS access key and secret key which need to be copied to ~/.boto file
Getting AWS access key and Secret key
Step3: Login to your aws console and follow below screenshots to get your AWS access key and secret key.
Once we get Access key ID and secure access key from above details write those details to .boto file.
Step4: Write your keys to ~/.boto file as shown below
[Credentials]
aws_access_key_id = AKIAJTKAWVR5TELVR4VA
aws_secret_access_key = wir9eklBfm8HQbDIlkxfIkOOpRb3VJ7mGFgVgu4a
We can add some other boto settings to this file like EC2 region and http socket time outs which are good to have but not mandatory. My settings as follows.
[Boto]
ec2_region_name = ap-southeast-2
http_socket_timeout = 10
Step5: Change permissions to your .boto files so that only you can read the file.
chmod 400 ~/.boto
That is it we are done with setting up our boto module. We can start coding AWS using this. Some example to test if we are able to access AWS or not.
List available regions
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credit's" or "license" for more information.
>>> import boto.ec2
>>> boto.ec2.regions()
[RegionInfo:us-east-1, RegionInfo:cn-north-1, RegionInfo:ap-northeast-1, RegionInfo:eu-west-1, RegionInfo:ap-southeast-1, RegionInfo:ap-southeast-2, RegionInfo:us-west-2, RegionInfo:us-gov-west-1, RegionInfo:us-west-1, RegionInfo:eu-central-1, RegionInfo:sa-east-1]
Hope this helps some one to setup boto stuff on their machine.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018