简体   繁体   中英

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

I would like to list all of my local profiles using boto3, as I think boto3 is not picking up my credentials correctly.

I have tried the following:

import boto3

boto3.Session.available_profiles

Which doesn't give me a list, but a property object.

You might want to use awscli instead of boto3 to list your profiles.

aws configure list

This should output something like this:

   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

As for boto3 , try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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