[PYTHON] use something other than the default profile with boto3

By default

import boto3

s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
    print(bucket.name)

Specify ACCESS_KEY and SECRET_KEY

document

import boto3
from boto3.session import Session

session = Session(aws_access_key_id='<YOUR ACCESS KEY ID>',
                  aws_secret_access_key='<YOUR SECRET KEY>',
                  region_name='<REGION NAME>')

s3 = session.resource('s3')

Specify by profile name in ~ / .aws / credentials

Pass profile_name to Session.

Documentation I can't understand it by looking at it, [github issue](https://github.com/boto/boto3/pull/ Found in 69)

import boto3
from boto3.session import Session

profile = '<YOUR_PROFILE_NAME>'
session = Session(profile_name=profile)

s3 = session.resource('s3')

Recommended Posts

use something other than the default profile with boto3
Use something other than a <br> string for the <br> dict key in Python
[Python] I want to add a static directory with Flask [I want to use something other than static]
Use the preview feature with aws-cli
Open the file with the default app
Use boto3 with temporary credentials with SAML authentication
To use the results obtained with scikit-learn's MLP Classifier in other services (languages)
Until you use the Kaggle API with Colab
Specify the Python executable to use with virtualenv
Use logger with Python for the time being
The easiest way to use OpenCV with python
Describe ec2 with boto3 and retrieve the value
Embed other images on the raster with ArcPy
Predict the distribution of continuous values ​​other than the normal distribution with ordinary PyTorch or TensorFlow