Created
May 8, 2015 02:17
-
-
Save lqez/bc019e56f463cbbbfbb1 to your computer and use it in GitHub Desktop.
Verify ELB's https connection
This file contains hidden or 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 boto.route53 | |
import boto.ec2.elb | |
import requests | |
region = 'ap-northeast-1' | |
# Get all records from Route53 | |
r53_conn = boto.route53.connect_to_region(region) | |
zones = r53_conn.get_zones() | |
aliases = dict() | |
for zone in zones: | |
for r in zone.get_records(): | |
if r.alias_dns_name: | |
aliases[r.alias_dns_name[:-1]] = r.name[:-1] | |
# Get all load balancers and match with Route53 records | |
elb_conn = boto.ec2.elb.connect_to_region(region) | |
elbs = elb_conn.get_all_load_balancers() | |
for elb in elbs: | |
for port in elb.listeners: | |
if port[0] != 443: | |
continue | |
for alias, name in aliases.iteritems(): | |
if elb.canonical_hosted_zone_name in alias: | |
try: | |
requests.get('https://' + name, verify=True) | |
except requests.exceptions.SSLError: | |
print name, elb.canonical_hosted_zone_name, 'has SSL problem.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment