AWS – Can’t Delete Route 53 Hosted Zone Error Message

In this blog post, I will show you how to delete an AWS Route 53 hosted Zone when you receive the Service Discovery error message.

If you are using AWS, you probably using Route 53 without even knowing, in the background when you provision AWS services like ECS, AWS Crete a local zone for you.

Error Message

Below is the error message, I had received when I tried to delete a Route 53 DNS Zone.

The resource hostedzone/Z1mx can only be managed through servicediscovery.amazonaws.com (arn:aws:servicediscovery:us-west-1:852051225911:namespace/ns-v2m5vcc3uqqdvej5)

Solution

To fix this error and delete the DNS zone we need to remove all the DNS Entries from the zone.

In this case, we need to use AWS CLI to delete all the records.

Once the records are deleted, I will delete the service.

The first step in this process is to run the command below, which lists all the services.

aws servicediscovery list-services

To delete each service I copy the value next to the “I’d” and run the command below:

aws servicediscovery delete-service --id srv-cad3ym6tdx2yixlx --region us-west-1

Once all services have been deleted, I will run the command below which will show me the namespaces.

In my case, the namespace below is the one that gives me the error message.

aws servicediscovery list-namespaces

To delete the namespace I run the command below.

aws servicediscovery delete-namespace --id ns-v2m5vcc3uqqdvej5

Once the namespace has been deleted, The zone will be deleted automatically as well.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.