Created
September 24, 2012 22:53
-
-
Save nikolajbaer/3778941 to your computer and use it in GitHub Desktop.
Delete a cert from Amazon
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
#!/usr/bin/python | |
# Usage: python manage_certs.py <ACCESS KEY> <SECRET KEY> <cert name to delete> | |
# NOTE: your access key user must have full EC2 Permissions and IAM permissions to run this | |
# NOTE: This script DELETES stuff, so make sure you read through it and think twice before saying "yes" when it prompts you! | |
from boto.iam.connection import IAMConnection | |
import boto | |
import sys,time,threading | |
import optparse | |
srckey, srcpasswd,target_cert = sys.argv[1:] | |
elb_conn = boto.connect_elb(aws_access_key_id = srckey, aws_secret_access_key = srcpasswd) | |
iam_conn = IAMConnection(srckey, srcpasswd) | |
#lbs = elb_conn.get_all_load_balancers() | |
#for lb in lbs: | |
# print lb | |
print "retrieving all certificates" | |
certs = iam_conn.get_all_server_certs() | |
cert_names = {} | |
for cert in certs["list_server_certificates_response"]["list_server_certificates_result"]["server_certificate_metadata_list"]: | |
print cert["server_certificate_name"] | |
cert_names[cert["server_certificate_name"]] = cert | |
if target_cert in cert_names: | |
print "You are looking to delete %s, are you sure you want to do this??? (yes/no)"%cert_names[target_cert] | |
if raw_input() == "yes": | |
print "I am deleting the cert %s"%target_cert | |
iam_conn.delete_server_cert(target_cert) | |
print "ok it should be deleted!" | |
else: | |
print "%s is not a cert you have"%target_cert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment