簡體   English   中英

如何使用 .aws 中的所有憑據來執行 Boto3 腳本?

[英]How to use all the credentials from .aws to execute Boto3 script?

我有一個可以使用的 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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM