Skip to content

Instantly share code, notes, and snippets.

@adamgoucher
Created April 11, 2016 14:48
Show Gist options
  • Save adamgoucher/de727f8b4825fb90891e8e2a719f382f to your computer and use it in GitHub Desktop.
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
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