AWS Cloud Automation with Python and Boto3 – Part 1
AWS is a well known Cloud provider and this article focuses on how automation helps to remove manual operations on AWS. So, lets get started and check out on scripting languages that help.
Lets take an example of operations that demand automation while uploading files to multiple S3 buckets-
a. find and list number of IAM (identity access management) users and groups in AWS
b. find inventory of all AWS resources (EC2, S3, load balancers, etc)
c. ensure VMs have backup policy to avoid data loss
d. install standard agents
e. list S3 buckets
For the above listed tasks, if the resource count is less then performing them manually is fine BUT if these resources are more than 2000, then definitely we need automation. This is where scripting languages like Python and Boto3 come to rescue.
Python is a platform independent open source programming language and Boto3 is AWS’s SDK for Python. Boto3 enables developers to create, configure and manage AWS services like EC2 and S3. Need to know more about Boto3, check out here – https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html
Lets learn how to install Python on Windows-
- Go to https://www.python.org?downloads .
- Select windows
- Download WindowsX86_64 executable installer
But how about installing Python on Linux…refer following commands –
- wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
- tar xjf Python-3.6.3.tar.xz
- cd Python-3.6.3
- ./configure
- make
- make in
To install Boto3 using pip, refer following command-
- pip install boto3
To install AWS CLI using pip, refer following command-
- pip install awscli –upgrade -user
To check whether AWS CLI is installe,refer following command-
- aws –version
And the output will look like below..
- aws-cli/1.11.34 Python/2.7.10 Darwin/15.6.0 botocore/1.4.91
Isn’t this easy ? Stay tuned for the next part on how to script using Python and Boto !!