Automating AWS EC2 Management with Python and Boto3

python_tutorials

Introduction

In this article I will be demonstrating the use of Python along with the Boto3 Amazon Web Services (AWS) Software Development Kit (SDK) which allows folks knowledgeable in Python programming to utilize the intricate AWS REST API’s to manage their cloud resources. Due to the vastness of the AWS REST API and associated cloud services I will be focusing only on the AWS Elastic Cloud Compute (EC2) service.

Here are the topics I will be covering:

  • Starting an EC2 instance
  • Stoping an EC2 instance
  • Terminating an EC2 instance
  • Backing up an EC2 instance by creating an image
  • Creating an EC2 instance from an image
  • Scheduling backup and clean up using cron on a server and AWS Lambda

Dependencies and Environment Setup

To start I will need to create a user in my AWS account that has programmatic access to the REST API’s. For simplicity I will be granting this user admin rights, but please note that is only for simplicity in creating this tutorial. If you are following along you should consult your organization’s IT security policies before using this user in a production environment.

Step 1: In my AWS console I must

To finish reading, please visit source site