Manage Amazon S3 Buckets with Python in minutes — Part 2

Ramon Marrero
Analytics Vidhya
Published in
5 min readApr 23, 2021

--

Use a familiar programming language like Python to create and access Amazon S3 resources.

Photo by Chris Ried on Unsplash

Introduction

In part 1 of this series, you can learn how to interact with Amazon S3 buckets using the AWS SDK Python (boto3). We were able to create and list buckets, as well as upload and download files from Amazon S3.

In this post, we will describe how to use Python to grant temporary access to the buckets and objects for users who do not have AWS credentials or permission to access S3 objects via Presigned URLs. Additionally, we will learn to manage bucket policies and bucket CORS configuration using Python.

Presigned URLs

When it comes to Amazon S3, all objects are private by default. The only entity with permission to access these objects is the object owner. However, using their own security credentials, the object owner can share objects with others by creating a presigned URL, and therefore granting time-limited permission to access the objects.

To create a presigned URL for an S3 object, you must provide several details:

  • Bucket name
  • Object key
  • HTTP method (GET to download the object)
  • Expiration date and…

--

--

Ramon Marrero
Analytics Vidhya

Head of Data Engineering | AWS Community Builder | AWS Certified Solutions Architect | Google Cloud Certified Professional