""" This program list all secrets and show their next rotation date if < 30d """ import boto3 from datetime import datetime, timezone print("Secret DaysToNextRotation NextRotationDate") sm_client = boto3.client('secretsmanager') paginator = sm_client.get_paginator('list_secrets') iterator = paginator.paginate() for page in iterator: for i in page.get('SecretList'): if i.get("NextRotationDate") is not None: NextRotationDate = i.get("NextRotationDate").replace(tzinfo=timezone.utc) Today = datetime.now(timezone.utc) Difference = (NextRotationDate - Today).days # if Difference < 20: print(i.get("Name"), Difference, NextRotationDate.date())