From 2c72a8677804e53153b8e30ad41b20d4c4e1cc8e Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Mon, 7 Mar 2016 19:25:25 +0000 Subject: [PATCH] Support HostedZoneId in RecordSet templates Signed-off-by: Jesse Szwedko --- moto/route53/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/moto/route53/models.py b/moto/route53/models.py index 17f6ac189..3a51b284f 100644 --- a/moto/route53/models.py +++ b/moto/route53/models.py @@ -77,8 +77,11 @@ class RecordSet(object): def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name): properties = cloudformation_json['Properties'] - zone_name = properties["HostedZoneName"] - hosted_zone = route53_backend.get_hosted_zone_by_name(zone_name) + zone_name = properties.get("HostedZoneName") + if zone_name: + hosted_zone = route53_backend.get_hosted_zone_by_name(zone_name) + else: + hosted_zone = route53_backend.get_hosted_zone(properties["HostedZoneId"]) record_set = hosted_zone.add_rrset(properties) return record_set @@ -112,6 +115,8 @@ class RecordSet(object): def delete(self, *args, **kwargs): ''' Not exposed as part of the Route 53 API - used for CloudFormation. args are ignored ''' hosted_zone = route53_backend.get_hosted_zone_by_name(self.hosted_zone_name) + if not hosted_zone: + hosted_zone = route53_backend.get_hosted_zone(self.hosted_zone_id) hosted_zone.delete_rrset_by_name(self.name)