Boto and Boto3
The following sections provide example information to help you install, configure, and use the Boto and Boto3 command-line tools. For additional information about these tools, refer to the product documentation listed under "Related Information" at the end of this section.
Note:
Boto and Boto3 are client functions in Amazon Web Services (AWS) Software Development Kit (SDK) for Python. Boto3 is the next generation of Boto and is available for general use.Installation Example: Boto and Boto3
Install the latest version of Boto or Boto3 using pip
, for
example:
pip install boto pip install boto3
Configuration Example: Boto and Boto3
Prior to using Boto (or Boto3), you need to set up authentication credentials. Authentication credentials can be configured in multiple ways. For instance, you can pass authentication credentials as parameter methods, environmental variables, or within a file such as a shared credentials file or an AWS configuration file. The following example defines the authentication credentials in an AWS configuration file.
cat ~/.aws/credentials [default] aws_access_key_id = YOUR_ID aws_secret_access_key = YOUR_SECRET
Usage Examples: Boto and Boto3
The following Boto and Boto3 examples show interaction with the Oracle ZFS Storage Appliance S3 Object API Service.
Boto:
#!/usr/bin/env python import boto import boto.s3.connection access_key = 'coma-04042017' secret_key = 'd0f8c646dc4303930c547b85ef549ce80aa0709f4720436ab8f24afeaebf80b9' conn = boto.connect_s3( aws_access_key_id = coma-04042017, aws_secret_access_key = d0f8c646dc4303930c547b85ef549ce80aa0709f4720436ab8f24afeaebf80b9, host = "x4200-85.us.example.com", # Storage appliance host name. port = 443, # Set to HTTPS port number for HTTPS connection. is_secure=True, # Set to True for HTTPS connection. debug = 2, path = "/s3/v1/export/coma", # Configured share S3 filesystem. calling_format=boto.s3.connection.OrdinaryCallingFormat() ) bucket = conn.create_bucket('new_bucket')
Boto3:
#!/usr/bin/env python import boto3 access_key = 'open-sesame' secret_key = 'ddc37fc17a3837dcb4757612cefa8f4cf0be9508b51b6d6a1087c24e3d7da95f' b3_session = boto3.Session(aws_access_key_id=access_key, aws_secret_access_key=secret_key, region_name='lalaland') b3_client = b3_session.client('s3', endpoint_url="https://192.0.2.0/s3/v1/export/mystore") bucket = b3_client.create_bucket(Bucket="newbucket")
Related Information
-
See the GitHub boto website for the latest versions of Boto or Boto3.
-
See the Boto 3 Documentation for installation, configuration, and use with Amazon S3.