Automating and Provisioning to Amazon AWS using boto3 SDK for Python 3
$25.00
Minimum price
$35.00
Suggested price

Automating and Provisioning to Amazon AWS using boto3 SDK for Python 3

Code written for boto3 Python3 SDK v.1.20

About the Book

Creation Date: 2021-10-01

Last Update: 2022-01-16 v. 16

This book covers the Amazon SDK for Python 3: boto3.

Across 128 pages, DIN-A4 full size, PDF only, DRM-free, it explains, since the beginning, how to create a CLI (Command Line Interface) application that uses Amazon's boto3 Python SDK to interact with Amazon AWS and do operations like:

  • Pass different credentials to boto3 as text (not just having on the default file locations)
  • Create new Instances
  • Start, Stop a Instance
  • Stop all the running instances
  • Start all the stopped instances
  • List Instances
  • Using tags
  • Create, Add, Remove, EBS Volumes
  • Create S3 Buckets, upload files, download files, list objects on a bucket
  • Add CloudWatch Alerts
  • Create tables in DynamoDB and perform Inserts
  • Also includes how to deploy AWS group of instances from Ansible, and install Apache to one of the group through an Ansible Playbook

...

Full Source Code included.

It's completely hands on, and most of the book is code and explanations related, so you'll be able to code your own Automations for Amazon and save many hours or investigation and try and error.

It teaches you all the stuff you need to Automate Operations against Amazon AWS with Python 3.

The programs are tested to work with Ubuntu Linux, but they should work on any Linux distro, on Mac and Windows. (with the exception of chmod which is a specific command for Linux and Mac, and one Bash sample for Ansible which uses grep, another specific utility for Linux)

  • Share this book

  • Categories

    • Computers and Programming
    • Amazon Web Services
    • Cloud Computing
    • Python
    • Ansible
  • Feedback

    Email the Author(s)

About the Author

Carles Mateo
Carles Mateo

I’m Carles Mateo, since January 2020 working as Operations Engineer for Blizzard Entertainment in Cork, Ireland.

Previously worked as Cloud Architect and SDM for Sanmina, in Ireland and United States, where I created and I did lead a Python and C project for a Storage Manager for our 4U Cold Storage Servers 1PB and 2U SSD and 1U NVMe with NICs up to 2x100Gbps, which will restore redundancy in the RAID when a drive dies, very quickly, using ZFS and DRAID.

I helped several multinationals:

  • Volkswagen IT (gedas) where I got promoted to head of department of Reusability and Code Components and previously I lead the SEAT's Intranet project, I solved TCP/Ip transmission problems in project PortIc for Barcelona's port (EDI Transfer), I created a project to transfer warranty documents over Web and TCP/IP instead of X.25 expensive lines, and worked for CaixaBank (formerly "la caixa") creating a Documentum solution programing the GUI and DLL's.
  • Winterthur Insurance (Axa) where I was Senior PM and I lead both technically and in functionally, the project to deploy a new Contact Center Software, the e-Commerce web platform and the insurance of health policies (special Data treatment)
  • BBVA Tickets where I was responsible of the platform (Sun Solaris and Oracle)

I worked a lot for CSP (Cloud Service Providers) and ISP, in Linux.

Also I helped many Start ups, e-Commerces, Online travel agencies... as CTO or in hands on positions leading teams and coding myself, in Software Development, SRE and Operation roles.

I was one of the 5 Senior BackEnds that wrote Privalia's new multi-country Website, from the scratch, with inheritance, and I lead a KPI Dashboards for CEO, really learning the internals of all the areas of the company through the data.

The last company I was CTO for, in Barcelona, was sold to airbnb for 45 million euros.

My friends say that everything I touch turns into gold, and my very good friend Jaume (R.I.P.) used to say that I was the most brutal technical guy, solving all the difficult technical issues easily, that he ever met. I've very grateful thoughts and memories for all the people that did speak up how well they considered me, and that were fair Other people tried to take advantage by never telling me how good and helpful I was, so they could pay me less. What they didn't know is that I always had offers paying me double, and I was choosing to help them.

Now I only accept fair agreements. I know my value.

I started programming when I was 5 years old, at 10 I won a contest at Spanish State level, getting a Pc with a green phosphorescent monitor and a floppy drive, and I've lived the times of the BBS, much before Internet.

I've coded many Freeware Software, and Open Source Software, and I created the first system in Europe to sell Tickets for musical events, in 1995, for Tick Tack Ticket. I created this e-Commerce engine, with render template system completely in C, cgi-bin, HTML.

I love Software and Hardware.

I've worked with C, Java, PHP, Python... and my knowledge of PHP Unit Testing really reached its best when I was working for a bank.

I've invented the CSort algorithm.

In my free time I teach some students to get pro in coding. Most of my time now I work with Python 3, Docker Containers and Linux.

You can find information about me in my blog.

https://blog.carlesmateo.com/bio

Bundles that include this book

$92.00
Bought separately
$42.00
Bundle Price

Table of Contents

  • Index...........................................................................3
  • Contact me.......................................................................6
  • Receiving Free Updates.............................................................6
  • If you’re not satisfied..............................................................6
  • MT Notation.....................................................................7
  • Why using Amazon AWS boto3......................................................9
  • Installing Amazon AWS boto3.......................................................9
  • Create the Credentials in Amazon AWS Console........................................15
  • Enabling a Default VPC.........................................................17
  • Configuring the Credentials........................................................18
  • Our first Python 3 sample..........................................................18
  • Error handling...................................................................20
  • boto3 and None Objects.........................................................20
  • Access to the Source Code showed in the book.........................................21
  • Programming the Application.......................................................22
  • Main file: assignment.py........................................................22
  • Credential passwords.txt file........................................................26
  • The MenuUtils class..............................................................26
  • Class KeyboardInputManagement...................................................29
  • Starting the program..............................................................30
  • Working with EC2................................................................30
  • Code lib/awsec2.py.............................................................31
  • Listing all the instances.........................................................39
  • Create an instance based on AMI: create_instance_asking().............................41
  • Stop a Running instance.........................................................49
  • Start a stopped instance.........................................................50
  • Create a new AMI Image based on an Instance.......................................51
  • Amazon boto3 Resources and Clients.................................................52
  • Client example: Creating Key Pairs................................................52
  • Starting all the stopped Instances..................................................53
  • Stopping all the Running Instances................................................53
  • Working with EBS (Elastic Block Storage)............................................54
  • Create a new Volume, with a Waiter................................................54
  • The code: ec2_client.create_volume()..............................................55
  • Prefix for Volumes: vol-.........................................................57
  • Listing EBS Volumes...........................................................57
  • The code for listing volumes.....................................................57
  • The code for get_all_volumes(s_filter_instance_id="").................................58
  • The boto3 resources call to get the volumes..........................................59
  • Attach an existing Volume to an Instance............................................60
  • Code for attaching a Volume to an Instance..........................................67
  • Typical problems attaching Volumes...............................................70
  • Detaching Volumes.............................................................70
  • Useful scenarios of detaching a Volume.............................................70
  • List own Snapshots.............................................................70
  • The code for ec2_client.describe_snapshots()........................................71
  • Taking a Snapshot of a Volume...................................................73
  • Creating a Volume from a Snapshot................................................73
  • S3 Storage......................................................................75
  • Create a Bucket................................................................75
  • The code for: ec2_s3_client.create_bucket().........................................76
  • List Buckets..................................................................77
  • Upload a File to S3.............................................................78
  • List all objects in a Bucket.......................................................79
  • Download an object from a Bucket................................................81
  • Delete an Object from a Bucket...................................................84
  • CloudWatch.....................................................................86
  • Create an Alarm..................................................................87
  • List Metrics...................................................................89
  • Retrieve a specific Metric (CPUUtilization).........................................90
  • Retrieve a specific Metric (LogicalDisk % Free Space)................................99
  • Create an Alarm with Action enabled, that will stop the instance when the CPU load is greater
  • than 60%....................................................................100
  • Using Amazon DynamoDB........................................................102
  • Create a table in DynamoDB (with Waiter).........................................103
  • Counting items on a Table......................................................105
  • Querying for a Table Creation Time...............................................106
  • Inserting Data (put)............................................................107
  • Delete a Table................................................................115
  • Ansible..........................................................................116
  • Prerequisites...................................................................116
  • Amazon’s AWS...............................................................116
  • Selection of the Image for the Master Node: Ubuntu 20.04 LTS.........................117
  • Installation of the Master node in Virtual Box.......................................117
  • Commands to install ansible in the Master Node in Ubuntu 20.04 LTS...................119
  • Testing ansible (outside the program)................................................120
  • Specifying Region (as an error showed, how I troubleshot)............................121
  • Specifying AWS Credentials....................................................122
  • Installing the ansible assignment program............................................122
  • Running ansible.py..............................................................123
  • How it works internally?..........................................................123
  • The scripts can be executed independently from command line.........................125
  • Problems (solved) with VPCs....................................................127
  • Doing all the sequence with the application...........................................132
  • How we control having two groups of instances?....................................133
  • Is better demoed with a video :)..................................................134
  • Later I added the task to list all the instance public Ips................................135
  • Installing Apache to the Deployed Instances (first version)...............................136
  • How I solved the problem with the Key Certificate...................................137
  • How I solved promoting user ubuntu to root........................................140
  • Final success.................................................................143
  • How to test that Apache works.....................................................145
  • Provisioning AWS EC2 Instances with Ansible and Automating Apache deployment with or without
  • using Ansible Dynamic Inventory from Ubuntu 20.04 LTS...............................146
  • Pre-requisites................................................................146
  • If you want to use Dynamic Inventory.............................................146
  • If you don’t want to use Dynamic Directory........................................149
  • Alternative way parsing with awk and grep......................................150

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub