d-_-b
d-_-b

Reputation: 4512

Boto3: Configuration file location

Is there any way to have Boto seek for the configuration files other than the default location, which is ~/.aws?

Upvotes: 12

Views: 20542

Answers (3)

gia huy
gia huy

Reputation: 369

Yes, you can:

from boto3 documentation

  • 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.

Please check the link for more information.

Upvotes: 0

VinsanityL
VinsanityL

Reputation: 830

Yes, you can install the configuration file (for site-wide settings that all users on this machine will use) in:

nano /etc/boto.cfg
[Credentials]
aws_access_key_id = your_key
aws_secret_access_key = your_password

Other possible locations could be:

  • (if profile is given) ~/.aws/credentials for credentials shared between SDKs
  • (if profile is given) ~/.boto for user-specific settings
  • ~/.aws/credentials for credentials shared between SDKs
  • ~/.boto for user-specific settings

Upvotes: 2

garnaat
garnaat

Reputation: 45906

It's not clear from the question whether you are talking about boto or boto3. Both allow you to use environment variables to tell it where to look for credentials and configuration files but the environment variables are different.

In boto3 you can use the environment variable AWS_SHARED_CREDENTIALS_FILE to tell boto3 where your credentials file is (by default, it is in ~/.aws/credentials. You can use AWS_CONFIG_FILE to tell it where your config file is (by default, it is in ~/.aws/config.

In boto, you can use BOTO_CONFIG to tell boto where to find its config file (by default it is in /etc/boto.cfg or ~/.boto.

Upvotes: 10

Related Questions