AWS Operations using Python

PURPOSE

Sharing a collection of snippets to perform common AWS operations such as Upload and Cache-Invalidation for S3 buckets, using Python.

Prerequisites

You should have the following keys before starting:

  • AWS Access Key
  • AWS Secret Key
  • AWS Distribution ID (optional, required for invalidating cache)

In a hurry? Grab this gist.


How to Upload a file with public access on an S3 Bucket

Note: If you don't want the access to be public, remove the ACL key in the ExtraArgs dictionary passed to upload_file function.


How to Invalidate Cache of a File in S3 Bucket

Thank the author. Fork this blog.


Tagged in pythonawsdevops