[英]Boto3: Configuration file location
有没有办法让 Boto 寻找默认位置以外的配置文件,即~/.aws
?
It's not clear from the question whether you are talking about boto or boto3.从问题中不清楚您是在谈论 boto 还是 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
.在 boto3 中,您可以使用环境变量AWS_SHARED_CREDENTIALS_FILE
来告诉 boto3 您的凭证文件在哪里(默认情况下,它在~/.aws/credentials
。您可以使用AWS_CONFIG_FILE
来告诉它您的配置文件在哪里(默认情况下,它在~/.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
.在 boto 中,您可以使用BOTO_CONFIG
告诉 boto 在哪里可以找到它的配置文件(默认情况下它在/etc/boto.cfg
或~/.boto
。
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:其他可能的位置可能是:
~/.aws/credentials
for credentials shared between SDKs (如果提供了配置文件) ~/.aws/credentials
用于 SDK 之间共享的凭据~/.boto
for user-specific settings (如果提供了配置文件) ~/.boto
用于用户特定的设置~/.aws/credentials
for credentials shared between SDKs ~/.aws/credentials
用于 SDK 之间共享的凭据~/.boto
for user-specific settings ~/.boto
用于用户特定的设置Yes, you can:是的你可以:
from boto3 documentation来自boto3 文档
Please check the link for more information.请查看链接以获取更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.