April 2018
Intermediate to advanced
280 pages
8h 37m
English
A simple example of creating an S3 bucket using Python is as follows. We first import the boto3 Python library in our application and then create an object of type S3. Then, using this object, we simply invoke the create_bucket() function and pass the name of the bucket to be created. The Bucket parameter of the create_bucket() function is mandatory. There are other parameters that are used to set the properties of the bucket such as permissions, region, and so on.
The following is the simplest implementation of the boto3 library, which will create a bucket named packt-pub-bucket:
import boto3s3 = boto3.resource('s3')s3.create_bucket(Bucket='packt-pub')
Notice that we created an S3 bucket by writing only three lines of ...