deleteHostedZone method

Future<DeleteHostedZoneResponse> deleteHostedZone({
  1. required String id,
})

Deletes a hosted zone.

If the hosted zone was created by another service, such as AWS Cloud Map, see Deleting Public Hosted Zones That Were Created by Another Service in the Amazon Route 53 Developer Guide for information about how to delete it. (The process is the same for public and private hosted zones that were created by another service.)

If you want to keep your domain registration but you want to stop routing internet traffic to your website or web application, we recommend that you delete resource record sets in the hosted zone instead of deleting the hosted zone. If you want to avoid the monthly charge for the hosted zone, you can transfer DNS service for the domain to a free DNS service. When you transfer DNS service, you have to update the name servers for the domain registration. If the domain is registered with Route 53, see UpdateDomainNameservers for information about how to replace Route 53 name servers with name servers for the new DNS service. If the domain is registered with another registrar, use the method provided by the registrar to update name servers for the domain registration. For more information, perform an internet search on "free DNS service."

You can delete a hosted zone only if it contains only the default SOA record and NS resource record sets. If the hosted zone contains other resource record sets, you must delete them before you can delete the hosted zone. If you try to delete a hosted zone that contains other resource record sets, the request fails, and Route 53 returns a HostedZoneNotEmpty error. For information about deleting records from your hosted zone, see ChangeResourceRecordSets.

To verify that the hosted zone has been deleted, do one of the following:

  • Use the GetHostedZone action to request information about the hosted zone.
  • Use the ListHostedZones action to get a list of the hosted zones associated with the current AWS account.

May throw NoSuchHostedZone. May throw HostedZoneNotEmpty. May throw PriorRequestNotComplete. May throw InvalidInput. May throw InvalidDomainName.

Parameter id : The ID of the hosted zone you want to delete.

Implementation

Future<DeleteHostedZoneResponse> deleteHostedZone({
  required String id,
}) async {
  ArgumentError.checkNotNull(id, 'id');
  _s.validateStringLength(
    'id',
    id,
    0,
    32,
    isRequired: true,
  );
  final $result = await _protocol.send(
    method: 'DELETE',
    requestUri: '/2013-04-01/hostedzone/${Uri.encodeComponent(id)}',
    exceptionFnMap: _exceptionFns,
  );
  return DeleteHostedZoneResponse.fromXml($result.body);
}