Files
code-dumps/py/SecretsRotationDate.py
T
2025-06-18 21:22:41 +08:00

21 lines
719 B
Python

"""
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())