Boto Config File

BotoAWS SDK for Python,能够经过pip安装,也能够下载源码直接安装。直接安装挺方便的。html

安装后参照AWS给出的Sample Project,链接S3,遍历一下buckets,获取指定的bucket,都挺简单的。python

可是忘记了作一件事,没有“export access keys to environment variables”。模仿Sample只能把access key ID和secret access key做为参数写在代码里。git

回过头看文档,再找到Boto Config的文档,而后就傻乎乎地试图去找到文档里提到的"boto.cfg"和".boto",折腾半天没找到。github

浪费很多时间以后才明白,boto installer是不会自动建立这个config文件的。手动建立一个,放到该放的地方就能够了。ide

哪些地方是该放的地方呢?Unix/Linux系统里,boto按照这个顺序寻找config文件。this

  • /etc/boto.cfg - for site-wide settings that all users on this machine will use
  • ~/.boto - for user-specific settings
  • ~/.aws/credentials - for credentials shared between SDKs

固然,这也不是必须的,能够把config文件放到任何地方,而后在环境变量里配置BOTO_CONFIG。若是是Windows系统咋办?Stackoverflow上这个问题的回答可行。code

  • Create your file with the name you want(e.g boto_config.cfg) and place it in a location of your choice
  • Create an environment variable with the Name='BOTO_CONFIG' and Value= file_location/file_name
  • Boto is now ready to work with credentials automatically configured!

固然,最权威的是仔细看Boto Config文档,这里也介绍了在config文件里如何配置Credentials。htm

相关文章
相关标签/搜索