From 4e9fba5f28b83082a3ca56179bff32db54b41332 Mon Sep 17 00:00:00 2001 From: Timothy Klopotoski Date: Tue, 23 Aug 2022 09:45:01 -0400 Subject: [PATCH] Route53 backend should be global (#5414) --- moto/route53/models.py | 2 +- .../test_route53_cloudformation.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/moto/route53/models.py b/moto/route53/models.py index ceb771bbe..e568d8ff6 100644 --- a/moto/route53/models.py +++ b/moto/route53/models.py @@ -249,7 +249,7 @@ class RecordSet(CloudFormationModel): def delete(self, account_id, region): # pylint: disable=unused-argument """Not exposed as part of the Route 53 API - used for CloudFormation""" - backend = route53_backends[account_id][region] + backend = route53_backends[account_id]["global"] hosted_zone = backend.get_hosted_zone_by_name(self.hosted_zone_name) if not hosted_zone: hosted_zone = backend.get_hosted_zone(self.hosted_zone_id) diff --git a/tests/test_route53/test_route53_cloudformation.py b/tests/test_route53/test_route53_cloudformation.py index 88d79bdec..a76b24536 100644 --- a/tests/test_route53/test_route53_cloudformation.py +++ b/tests/test_route53/test_route53_cloudformation.py @@ -224,3 +224,21 @@ def test_route53_with_update(): record_set = rrsets[0] record_set["ResourceRecords"][0]["Value"].should.equal("my_other.example.com") + + +@mock_cloudformation +@mock_route53 +def test_delete_route53_recordset(): + + cf = boto3.client("cloudformation", region_name="us-west-1") + + # given a stack with a record set + stack_name = "test_stack_recordset_delete" + template_json = json.dumps(route53_health_check.template) + + cf.create_stack(StackName=stack_name, TemplateBody=template_json) + + # when the stack is deleted + cf.delete_stack(StackName=stack_name) + + # then it should not error