python-3.x - 如何使用 .aws 中的所有凭据执行 Boto3 脚本?
问题描述
我有一个可以使用的 boto3 脚本。当我从 .aws 凭据文件中指定配置文件名称时,它工作正常。但是,我想在我的 .aws 凭证文件中存在的所有配置文件中运行该脚本。而且,我有 20 多个个人资料。如何自动配置 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'])
解决方案
看起来有一个功能可以列出本地 .aws/credentials 文件中的所有配置文件。
for profile in boto3.session.Session().available_profiles:
print(profile)
推荐阅读
- flutter - 我如何使用颤振与其他预装的应用程序(如 WhatsApp)进行交互?
- github - 在gitlab中合并后如何自动推送到GitHub
- flutter - 如何添加加载屏幕以掩盖应用程序启动时显示的登录页面?
- nginx - Nginx:启动微服务并回退到部署服务器
- java - 在 Jenkins 中完成构建执行后,如何在 JIRA 票证中为任何失败的测试用例添加注释?
- android - 当线程中的响应发生变化时如何停止服务?
- linux - Shell脚本无助于杀死tomcat应用程序
- javascript - 如何使用javascript中的参数删除html表中的行
- c++ - 在命名空间 C++ 中创建类
- react-native - 如何在 React Native 中输入标签