python - 在 Python 的 boto.cfg 中获取凭证文件

标签 python amazon-web-services boto

我是第一次使用 AWS,刚刚安装了 boto for python。我被困在它建议的步骤:

“您可以将此文件放在/etc/boto.cfg 以供系统范围使用,或者放在以 ~/.boto 形式执行命令的用户的主目录中。”

老实说,我不知道该怎么办。首先,我找不到 boto.cfg,其次我不确定要为第二个选项执行哪个命令。

此外,当我将应用程序部署到我的服务器时,我假设我也需要在那里做同样的事情...

最佳答案

"You can place this file either at /etc/boto.cfg for system-wide use or in the home directory of the user executing the commands as ~/.boto."

前者只是意味着您可以在目录 /etc 中创建一个名为 boto.cfg 的配置文件(即它不一定已经存在,具体取决于如何boto 已安装在您的特定系统上)。

后者的措辞确实有点不幸 - ~/.boto 意味着 boto 将在用户执行的主目录中查找名为 .boto 的配置文件促进 boto 库的命令(即 Python 脚本)。

您可以在 boto wiki 文章 BotoConfig 中阅读更多相关信息,例如关于手头的问题:

A boto config file is simply a .ini format configuration file that specifies values for options that control the behavior of the boto library. Upon startup, the boto library looks for configuration files in the following locations and in the following order:

  1. /etc/boto.cfg - for site-wide settings that all users on this machine will use
  2. ~/.boto - for user-specific settings

您确实还需要在部署应用程序的服务器上准备相应的配置文件。

祝你好运!

关于python - 在 Python 的 boto.cfg 中获取凭证文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9197385/

相关文章:

python - 禁用 Nose 的一个示例测试

powershell - 从 powershell 运行 aws emr create-cluster 时出错

amazon-web-services - 如何从AWS CDK for python中的Bucket对象获取存储桶名称

amazon-web-services - Boto 可以通过 EKS 服务帐户承担角色吗

python - 使用numpy模拟1000种含有三种成分的气体混合物

python - 使用 python 线程锁和循环导入时的意外行为

python - 如何查找制表符分隔文件中的列数

amazon-web-services - 如何使用 AWS CDK 创建与 EC2 实例的弹性 IP 关联?

python - 使用Boto改善SimpleDB查询性能

pycharm - 属性错误 : partially initialized module 'boto3' has no attribute 'resource' (most likely due to a circular import)