我想使用 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)
关于python - 您如何从 ~/.aws/.credentials 和 ~/.aws/.config 文件中使用 boto3 列出本地配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64985488/