The first logical thing to do, when interacting with an AWS S3 service, is create a bucket that can be used to store files. In that case, we will provide the S3 to the boto3.resource() . That will tell the boto3 to start the initialization process and will load required commands to interact with the S3 API system:
import boto3s3_resource = boto3.resource("s3")bucket = s3_resource.create_bucket(Bucket="my_first_bucket", CreateBucketConfiguration={ 'LocationConstraint': 'us-west-2'})print(bucket)
In the preceding example, the following applies:
- We imported the boto3 module that we installed previously.
- Then, we specified a resource type that we wanted to interact with, which is s3, and assigned that to the s3_resource object. ...