Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion localstack-core/localstack/services/route53/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
ChangeStatus,
CreateHostedZoneResponse,
DeleteHealthCheckResponse,
DeleteHostedZoneResponse,
DNSName,
GetChangeResponse,
GetHealthCheckResponse,
Expand All @@ -36,6 +37,12 @@ def accept_state_visitor(self, visitor: StateVisitor):
visitor.visit(route53_backends)
visitor.visit(route53_stores)

# No tag deletion logic to handle in Community. Overwritten in Pro implementation.
def remove_resource_tags(
self, context: RequestContext, resource_type: str, resource_id: str
) -> None:
return

def create_hosted_zone(
self,
context: RequestContext,
Expand Down Expand Up @@ -114,6 +121,13 @@ def get_health_check(
)
)

def delete_hosted_zone(
self, context: RequestContext, id: ResourceId, **kwargs
) -> DeleteHostedZoneResponse:
response = call_moto(context)
self.remove_resource_tags(context=context, resource_type="hostedzone", resource_id=id)
return response

def delete_health_check(
self, context: RequestContext, health_check_id: HealthCheckId, **kwargs
) -> DeleteHealthCheckResponse:
Expand All @@ -126,4 +140,8 @@ def delete_health_check(
)

route53_backends[context.account_id][context.partition].delete_health_check(health_check_id)
return {}
self.remove_resource_tags(
context=context, resource_type="healthcheck", resource_id=health_check_id
)

return DeleteHealthCheckResponse()
5 changes: 4 additions & 1 deletion localstack-core/localstack/testing/pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,10 @@ def factory(**kwargs):
yield factory

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


@pytest.fixture
Expand Down
14 changes: 14 additions & 0 deletions tests/aws/services/route53/test_route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,17 @@ def test_reusable_delegation_sets(self, aws_client):
with pytest.raises(Exception) as ctx:
client.get_reusable_delegation_set(Id=set_id_1)
assert "NoSuchDelegationSet" in str(ctx.value)

@markers.aws.validated
def test_delete_hosted_zone(self, aws_client, hosted_zone, snapshot):
hosted_zone_response = hosted_zone(Name=f"zone-{short_uid()}.com")
hosted_zone_id = hosted_zone_response["HostedZone"]["Id"].split("/")[-1]

snapshot.add_transformer(snapshot.transform.regex(hosted_zone_id, "<hosted-zone-id>"))

with pytest.raises(ClientError) as e:
aws_client.route53.delete_hosted_zone(Id=hosted_zone_id + "asdf1234")
snapshot.match("no-such-hosted-zone-error", e.value.response)

delete_hosted_zone_response = aws_client.route53.delete_hosted_zone(Id=hosted_zone_id)
snapshot.match("delete-hosted-zone-response", delete_hosted_zone_response)
27 changes: 27 additions & 0 deletions tests/aws/services/route53/test_route53.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,32 @@
}
}
}
},
"tests/aws/services/route53/test_route53.py::TestRoute53::test_delete_hosted_zone": {
"recorded-date": "12-01-2026, 00:07:24",
"recorded-content": {
"no-such-hosted-zone-error": {
"Error": {
"Code": "NoSuchHostedZone",
"Message": "No hosted zone found with ID: <hosted-zone-id>asdf1234",
"Type": "Sender"
},
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 404
}
},
"delete-hosted-zone-response": {
"ChangeInfo": {
"Id": "/change/<change-id>",
"Status": "<status:1>",
"SubmittedAt": "datetime"
},
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 200
}
}
}
}
}
9 changes: 9 additions & 0 deletions tests/aws/services/route53/test_route53.validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
"tests/aws/services/route53/test_route53.py::TestRoute53::test_crud_health_check": {
"last_validated_date": "2024-06-13T08:05:47+00:00"
},
"tests/aws/services/route53/test_route53.py::TestRoute53::test_delete_hosted_zone": {
"last_validated_date": "2026-01-12T00:07:24+00:00",
"durations_in_seconds": {
"setup": 0.66,
"call": 0.74,
"teardown": 0.1,
"total": 1.5
}
},
"tests/aws/services/route53/test_route53.py::TestRoute53::test_reusable_delegation_sets": {
"last_validated_date": "2024-06-13T07:43:08+00:00"
}
Expand Down
Loading