Created
April 11, 2016 14:48
-
-
Save adamgoucher/de727f8b4825fb90891e8e2a719f382f to your computer and use it in GitHub Desktop.
A 'monday morning' script to see if you need to renew some certificates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
longest = 0; | |
data = {} | |
client = boto3.client('iam') | |
for certificate in client.list_server_certificates()['ServerCertificateMetadataList']: | |
if len(certificate['ServerCertificateName']) > longest: | |
longest = len(certificate['ServerCertificateName']) | |
data[certificate['Expiration']] = { | |
'name': certificate['ServerCertificateName'], | |
'expiry': certificate['Expiration'] | |
} | |
print("{0: <{1}s} Expiry".format("Certificate", longest)) | |
print("{0:_<{1}s} {2: <{3}s} ______".format("", len("Certificate"), "", longest - len("Certificate") - 1)) | |
for d in sorted(data.keys()): | |
print("{0: <{1}s} {2}".format(data[d]['name'], longest, data[d]['expiry'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment