[英]How to use all the credentials from .aws to execute Boto3 script?
I have a boto3 script ready to use.我有一个可以使用的 boto3 脚本。 It is working fine when I specify a profile name from my .aws credentials file.
当我从我的 .aws 凭据文件中指定配置文件名称时,它工作正常。 But, I want to run the script in all the profiles which are present in my .aws credentials file.
但是,我想在我的 .aws 凭据文件中存在的所有配置文件中运行该脚本。 And, I have like more than 20 profiles.
而且,我喜欢 20 多个配置文件。 How do I automatically configure boto3 to keep fetching the profiles one by one and return the output ?
如何自动配置 boto3 以继续一一获取配置文件并返回输出?
#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'])
Looks like there is a function to list out all the profiles in your local .aws/credentials file.看起来有一个函数可以列出本地 .aws/credentials 文件中的所有配置文件。
for profile in boto3.session.Session().available_profiles:
print(profile)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.