How To Automate AWS S3 Static Websites Using Python

Amazon Web Services offers a very popular object storage service known as Amazon S3 (Simple Storage Service) that enables you to store data, files, images and even videos in highly available containers called ‘buckets’ which are also easy to access endpoints using any popular programming language. In a combination of AWS S3 and with other AWS services developers can build scalable and durable applications and back ends.

In this article, we will demonstrate how to automate the creation of an AWS S3 Bucket, which we will use to deploy a static website using the AWS SDK for Python also known as the Boto3 library. Please refer to my previous article here to grant programmatic access from AWS and set up the environment local computer with AWS credentials.

Let’s start with fetching details of existing S3 buckets from AWS Cloud

List existing buckets

To list all Buckets in your console using Python, simply import the boto3 library in Python and then use the ‘list_buckets()’ method of the S3 client, then iterate through all the buckets available to list the property ‘Name’ like in the following image.
import boto3
s3 = boto3.client('s3')
response = s3.list_buckets()
for bucket in response['Buckets']:
print('BucketName: {}'.format(bucket['Name']))

Read More at IpSwitch.com


My new book: PowerShell Scripting Guide to Python

This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.

“Use what you know to learn what you don’t. ” also known as Associative learning.

Book follows a comparative method to jump start readers journey in Python, but who is the target audience? and who should read this book –

  • Any System Administrator who want to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
  • Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.

Python is one of the top programming languages and in fast changing IT scenarios to DevOps and Cloud to the future – Data ScienceArtificial Intelligence (AI) and Machine Learning Python is a must know.

But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell

NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!

While the book is in progress, please review it and send any feedback or error corrections at [email protected]

Optical Character Recognition

Subscribe to our mailing list

* indicates required