Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit 72ddf62

Browse files
authored
Route53: Move tagging logic into Provider methods (#13606)
1 parent 9f9e8ea commit 72ddf62

5 files changed

Lines changed: 73 additions & 2 deletions

File tree

localstack-core/localstack/services/route53/provider.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ChangeStatus,
1212
CreateHostedZoneResponse,
1313
DeleteHealthCheckResponse,
14+
DeleteHostedZoneResponse,
1415
DNSName,
1516
GetChangeResponse,
1617
GetHealthCheckResponse,
@@ -36,6 +37,12 @@ def accept_state_visitor(self, visitor: StateVisitor):
3637
visitor.visit(route53_backends)
3738
visitor.visit(route53_stores)
3839

40+
# No tag deletion logic to handle in Community. Overwritten in Pro implementation.
41+
def remove_resource_tags(
42+
self, context: RequestContext, resource_type: str, resource_id: str
43+
) -> None:
44+
return
45+
3946
def create_hosted_zone(
4047
self,
4148
context: RequestContext,
@@ -114,6 +121,13 @@ def get_health_check(
114121
)
115122
)
116123

124+
def delete_hosted_zone(
125+
self, context: RequestContext, id: ResourceId, **kwargs
126+
) -> DeleteHostedZoneResponse:
127+
response = call_moto(context)
128+
self.remove_resource_tags(context=context, resource_type="hostedzone", resource_id=id)
129+
return response
130+
117131
def delete_health_check(
118132
self, context: RequestContext, health_check_id: HealthCheckId, **kwargs
119133
) -> DeleteHealthCheckResponse:
@@ -126,4 +140,8 @@ def delete_health_check(
126140
)
127141

128142
route53_backends[context.account_id][context.partition].delete_health_check(health_check_id)
129-
return {}
143+
self.remove_resource_tags(
144+
context=context, resource_type="healthcheck", resource_id=health_check_id
145+
)
146+
147+
return DeleteHealthCheckResponse()

localstack-core/localstack/testing/pytest/fixtures.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,10 @@ def factory(**kwargs):
24892489
yield factory
24902490

24912491
for zone_id in zone_ids[::-1]:
2492-
aws_client.route53.delete_hosted_zone(Id=zone_id)
2492+
try:
2493+
aws_client.route53.delete_hosted_zone(Id=zone_id)
2494+
except ClientError as e:
2495+
LOG.debug("failed to delete hosted zone %s: %s", zone_id, e)
24932496

24942497

24952498
@pytest.fixture

tests/aws/services/route53/test_route53.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,17 @@ def test_reusable_delegation_sets(self, aws_client):
222222
with pytest.raises(Exception) as ctx:
223223
client.get_reusable_delegation_set(Id=set_id_1)
224224
assert "NoSuchDelegationSet" in str(ctx.value)
225+
226+
@markers.aws.validated
227+
def test_delete_hosted_zone(self, aws_client, hosted_zone, snapshot):
228+
hosted_zone_response = hosted_zone(Name=f"zone-{short_uid()}.com")
229+
hosted_zone_id = hosted_zone_response["HostedZone"]["Id"].split("/")[-1]
230+
231+
snapshot.add_transformer(snapshot.transform.regex(hosted_zone_id, "<hosted-zone-id>"))
232+
233+
with pytest.raises(ClientError) as e:
234+
aws_client.route53.delete_hosted_zone(Id=hosted_zone_id + "asdf1234")
235+
snapshot.match("no-such-hosted-zone-error", e.value.response)
236+
237+
delete_hosted_zone_response = aws_client.route53.delete_hosted_zone(Id=hosted_zone_id)
238+
snapshot.match("delete-hosted-zone-response", delete_hosted_zone_response)

tests/aws/services/route53/test_route53.snapshot.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,32 @@
142142
}
143143
}
144144
}
145+
},
146+
"tests/aws/services/route53/test_route53.py::TestRoute53::test_delete_hosted_zone": {
147+
"recorded-date": "12-01-2026, 00:07:24",
148+
"recorded-content": {
149+
"no-such-hosted-zone-error": {
150+
"Error": {
151+
"Code": "NoSuchHostedZone",
152+
"Message": "No hosted zone found with ID: <hosted-zone-id>asdf1234",
153+
"Type": "Sender"
154+
},
155+
"ResponseMetadata": {
156+
"HTTPHeaders": {},
157+
"HTTPStatusCode": 404
158+
}
159+
},
160+
"delete-hosted-zone-response": {
161+
"ChangeInfo": {
162+
"Id": "/change/<change-id>",
163+
"Status": "<status:1>",
164+
"SubmittedAt": "datetime"
165+
},
166+
"ResponseMetadata": {
167+
"HTTPHeaders": {},
168+
"HTTPStatusCode": 200
169+
}
170+
}
171+
}
145172
}
146173
}

tests/aws/services/route53/test_route53.validation.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
"tests/aws/services/route53/test_route53.py::TestRoute53::test_crud_health_check": {
1515
"last_validated_date": "2024-06-13T08:05:47+00:00"
1616
},
17+
"tests/aws/services/route53/test_route53.py::TestRoute53::test_delete_hosted_zone": {
18+
"last_validated_date": "2026-01-12T00:07:24+00:00",
19+
"durations_in_seconds": {
20+
"setup": 0.66,
21+
"call": 0.74,
22+
"teardown": 0.1,
23+
"total": 1.5
24+
}
25+
},
1726
"tests/aws/services/route53/test_route53.py::TestRoute53::test_reusable_delegation_sets": {
1827
"last_validated_date": "2024-06-13T07:43:08+00:00"
1928
}

0 commit comments

Comments
 (0)