0
votes

I have a boto3 script ready to use. It is working fine when I specify a profile name from my .aws credentials file. But, I want to run the script in all the profiles which are present in my .aws credentials file. And, I have like more than 20 profiles. How do I automatically configure boto3 to keep fetching the profiles one by one and return the output ?

#Listing the validity of SSL certs in RDS
import boto3
from pprint import pprint

rds = boto3.client('rds')

sslcert = rds.describe_certificates()

for cert in sslcert['Certificates']:
    print('Valid till', cert['ValidTill'])
1
There is no built-in capability to do this. You will need to extract a list of profiles and then loop through each one, creating a new boto3 client that uses that particular profile.John Rotenstein

1 Answers

1
votes

Looks like there is a function to list out all the profiles in your local .aws/credentials file.

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