Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Route53 Record.set_alias was broken by the addition of target health evaluation #2126

Merged
merged 2 commits into from

2 participants

Jim Browne Daniel G. Taylor
Jim Browne

Fix breakage and add tests for the new usage and original usage. Include health evaluation status in to_print.

I honestly am not sure if the default should be True or False; all of my pre-existing Route53 records report True when using the newer API, so I chose True as the default (though the docs note this may break for CloudFront targets.)

jimbrowne added some commits
Jim Browne jimbrowne Route53 Record.set_alias was broken by the addition of target
health evaluation.  Fix this and add tests for the new usage
and original usage.  Include health evaluation status in to_print.
34fd139
Jim Browne jimbrowne Fix route53 alias to_print and change default health eval to False e8e1de1
Jim Browne

I had an incorrect addition to the to_print as alias_evaluate_target_health is handled as a string rather than converted to a proper boolean. Based on that fix I've changed the default to False as that matches all of my existing Route53 records created with the old Route53 API.

Daniel G. Taylor danielgtaylor self-assigned this
Daniel G. Taylor

Thanks for the fix and tests :+1:

Daniel G. Taylor danielgtaylor merged commit 141077f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 27, 2014
  1. Jim Browne

    Route53 Record.set_alias was broken by the addition of target

    jimbrowne authored
    health evaluation.  Fix this and add tests for the new usage
    and original usage.  Include health evaluation status in to_print.
  2. Jim Browne
This page is out of date. Refresh to see the latest.
6 boto/route53/record.py
View
@@ -254,10 +254,12 @@ def add_value(self, value):
"""Add a resource record value"""
self.resource_records.append(value)
- def set_alias(self, alias_hosted_zone_id, alias_dns_name):
+ def set_alias(self, alias_hosted_zone_id, alias_dns_name,
+ alias_evaluate_target_health=False):
"""Make this an alias resource record set"""
self.alias_hosted_zone_id = alias_hosted_zone_id
self.alias_dns_name = alias_dns_name
+ self.alias_evaluate_target_health = alias_evaluate_target_health
def to_xml(self):
"""Spit this resource record set out as XML"""
@@ -310,6 +312,8 @@ def to_print(self):
if self.alias_hosted_zone_id is not None and self.alias_dns_name is not None:
# Show alias
rr = 'ALIAS ' + self.alias_hosted_zone_id + ' ' + self.alias_dns_name
+ if self.alias_evaluate_target_health is not None:
+ rr += ' (EvalTarget %s)' % self.alias_evaluate_target_health
else:
# Show resource record(s)
rr = ",".join(self.resource_records)
33 tests/integration/route53/test_alias_resourcerecordsets.py
View
@@ -1,4 +1,5 @@
# Copyright (c) 2014 Netflix, Inc. Stefan Praszalowicz
+# Copyright (c) 2014 42Lines, Inc. Jim Browne
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -79,5 +80,37 @@ def test_add_alias(self):
rrs.commit()
+ def test_set_alias(self):
+ base_record = dict(name="alias.%s." % self.base_domain,
+ type="A",
+ identifier="boto:TestRoute53AliasResourceRecordSets")
+
+ rrs = ResourceRecordSets(self.conn, self.zone.id)
+ new = rrs.add_change(action="UPSERT", **base_record)
+ new.set_alias(self.zone.id, "target.%s" % self.base_domain, False)
+ rrs.commit()
+
+ rrs = ResourceRecordSets(self.conn, self.zone.id)
+ delete = rrs.add_change(action="DELETE", **base_record)
+ delete.set_alias(self.zone.id, "target.%s" % self.base_domain, False)
+ rrs.commit()
+
+
+ def test_set_alias_backwards_compatability(self):
+ base_record = dict(name="alias.%s." % self.base_domain,
+ type="A",
+ identifier="boto:TestRoute53AliasResourceRecordSets")
+
+ rrs = ResourceRecordSets(self.conn, self.zone.id)
+ new = rrs.add_change(action="UPSERT", **base_record)
+ new.set_alias(self.zone.id, "target.%s" % self.base_domain)
+ rrs.commit()
+
+ rrs = ResourceRecordSets(self.conn, self.zone.id)
+ delete = rrs.add_change(action="DELETE", **base_record)
+ delete.set_alias(self.zone.id, "target.%s" % self.base_domain)
+ rrs.commit()
+
+
if __name__ == '__main__':
unittest.main()
Something went wrong with that request. Please try again.