Last active
March 16, 2016 20:15
-
-
Save micahhausler/7662214 to your computer and use it in GitHub Desktop.
Set a domain to an ELB
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 boto | |
from boto.route53.record import ResourceRecordSets | |
import json | |
subdomain = 'twitter' | |
primary_domain = 'tryambition.com' | |
load_balancer_name = 'elb-2' | |
elb_conn = boto.connect_elb() | |
r53_conn = boto.connect_route53() | |
zone = r53_conn.get_zone(primary_domain) | |
a_name = '{}.{}'.format(subdomain, primary_domain) | |
elb = elb_conn.get_all_load_balancers(load_balancer_names=[load_balancer_name])[0] | |
new_rrs = ResourceRecordSets(connection=r53_conn, | |
hosted_zone_id=zone.id, | |
comment='Adding DNS to ELB') | |
new_rrs.add_change(action='CREATE', | |
name=a_name, | |
type='A', | |
alias_dns_name=elb.dns_name, | |
alias_hosted_zone_id=elb.canonical_hosted_zone_name_id) | |
commit_dict = new_rrs.commit() | |
print json.dumps(commit_dict, indent=4) | |
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
{ | |
"ChangeResourceRecordSetsResponse": { | |
"ChangeInfo": { | |
"Status": "PENDING", | |
"Comment": "Adding DNS to ELB", | |
"SubmittedAt": "2013-11-26T15:39:40.764Z", | |
"Id": "/change/D3B7418OFQCOHR" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment