Pavan Rao
Pavan Rao

Reputation: 429

Can't delete a private hosted zone in AWS Route53

I am unable to delete Private Hosted Zone from console and CLI.

Please check below screen shot

enter image description here

Its throwing following error

The resource hostedzone/Z346QOK8DECBDU can only be managed through servicediscovery.amazonaws.com (arn:aws:servicediscovery:us-east-1:757712384777:namespace/ns-oekfhwgvesmkdb4i)

Private zone has following records enter image description here

I have tried deleting using AWS CLI commands as well

aws servicediscovery list-services
aws servicediscovery delete-service --id=ID-FROM-LIST
aws servicediscovery delete-namespace --id=NS-LIST

This did not work. I got following error

An error occurred (NamespaceNotFound) when calling the DeleteNamespace operation: NS-LIST

An error occurred (ServiceNotFound) when calling the DeleteService operation: ID-FROM-LIST

Please let me know if there is any other way.

Upvotes: 3

Views: 4947

Answers (3)

stevec
stevec

Reputation: 52228

I couldn't delete the hosted zone because the 'delete' button was greyed out. If I tried to delete the zone without deleting the records I'd just get:

Error occurred Before you can delete a hosted zone, you must first delete all resource record sets except the NS and SOA resource record sets for the zone apex. (HostedZoneNotEmpty 400: The specified hosted zone contains non-required resource record sets and so cannot be deleted.)

Solution

Click on the zone and select each record one at a time (via the checkbox on the left hand side), and delete all the records it lets you delete (not all can be deleted, but you must delete every record it allows you to delete before you can delete the zone).

Once each of the individual records that are possible to delete, then it will let you delete the zone.

Upvotes: 0

Prathiba
Prathiba

Reputation: 41

It is very simple if you have access to console

Search for “AWS cloud map” in aws console – > you can see than namespace – go inside namespace -> delete services -> go back and delete namespace -> check in your route53 console, hosted zone wont be there

Upvotes: 4

Sangam Belose
Sangam Belose

Reputation: 4506

Try to delete the AWS ECS service, which is using this hosted zone from AWS console, and then if you have any service discovery resources (like namespace), then delete those using below commands:

  1. Use below command to list services in specific region:

    aws servicediscovery list-services --region <region_name>
    
  2. If no services associated, then try to find the namespaces:

    aws servicediscovery list-namespaces --region <region_name>
    
  3. Then you can delete the namespace as below:

    aws servicediscovery delete-namespace --id <service_discovery_namespace_id> --region <region_name>
    

From output, It seems you don't have any services listed, but still try with --region option.

Your namespace_id seems to be incorrectly passed. Its arn is already shown in first error message.

To delete the private hosted zone:

To delete a private hosted zone that Amazon ECS created when you created a service using service discovery, delete the Amazon ECS services that are using the namespace, and delete the namespace

Ref:

  1. https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zone-private-deleting.html
  2. https://docs.aws.amazon.com/AmazonECS/latest/developerguide/delete-service.html

Upvotes: 6

Related Questions