Access s3 boto3 client with profile - or other service with python
- bdata3
- Feb 20, 2020
- 1 min read
Sometimes you need to access your aws services with specific profile (or not default)
The easiest way to do so :
import boto3
new_session = boto3.session.Session(profile_name='your_aws_profile')
s3 = new_session.client('s3')
response = s3.list_buckets()
# Output the bucket names
print('Existing buckets:')
for bucket in response['Buckets']:
print(f' {bucket["Name"]}')

Comments