2 Answers
- Newest
- Most votes
- Most comments
0
Hello.
boto3 will read the authentication information of "~/.aws/credentials" set for the OS user who executed the script without including the code below.
The authentication information to be read is "default", so if you have set a different profile, you will need to specify the profile using the code below.
aws_management_console = boto3.session.Session(profile_name="default")
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
Boto3 will look in several locations when searching for credentials. The mechanism in which Boto3 looks for credentials is to search through a list of possible locations and stop as soon as it finds credentials. The order in which Boto3 searches for credentials is:
- Passing credentials as parameters in the boto.client() method
- Passing credentials as parameters when creating a Session object
- Environment variables
- Shared credential file (~/.aws/credentials)
- AWS config file (~/.aws/config)
- Assume Role provider
- Boto2 config file (/etc/boto.cfg and ~/.boto)
- Instance metadata service on an Amazon EC2 instance that has an IAM role configured.
Relevant content
- asked 2 years ago
- asked 7 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
By the way, if the environment running boto3 is EC2, you can use IAM roles, so there is no need to configure "~/.aws/credentials".