繁体   English   中英

您如何从 ~/.aws/.credentials 和 ~/.aws/.config 文件中使用 boto3 列出本地配置文件?

[英]How do you list local profiles with boto3 from ~/.aws/.credentials and ~/.aws/.config files?

我想使用 boto3 列出我所有的本地配置文件,因为我认为 boto3 没有正确获取我的凭据。

我尝试了以下方法:

import boto3

boto3.Session.available_profiles

这没有给我一个列表,而是一个属性对象。

您可能希望使用awscli而不是boto3来列出您的个人资料。

aws configure list

这应该输出如下内容:

   Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************ABCD      config_file    ~/.aws/config
secret_key     ****************ABCD      config_file    ~/.aws/config
    region                us-west-2              env    AWS_DEFAULT_REGION

至于boto3 ,试试这个:

for profile in boto3.session.Session().available_profiles:
    print(profile)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM