api_op_DeleteHostedZone.go (5552B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package route53 4 5 import ( 6 "context" 7 8 "github.com/aws/aws-sdk-go-v2/service/route53/types" 9 "github.com/aws/smithy-go/middleware" 10 ) 11 12 // Deletes a hosted zone. 13 // 14 // If the hosted zone was created by another service, such as Cloud Map, see [Deleting Public Hosted Zones That Were Created by Another Service] in 15 // the Amazon Route 53 Developer Guide for information about how to delete it. (The 16 // process is the same for public and private hosted zones that were created by 17 // another service.) 18 // 19 // If you want to keep your domain registration but you want to stop routing 20 // internet traffic to your website or web application, we recommend that you 21 // delete resource record sets in the hosted zone instead of deleting the hosted 22 // zone. 23 // 24 // If you delete a hosted zone, you can't undelete it. You must create a new 25 // hosted zone and update the name servers for your domain registration, which can 26 // require up to 48 hours to take effect. (If you delegated responsibility for a 27 // subdomain to a hosted zone and you delete the child hosted zone, you must update 28 // the name servers in the parent hosted zone.) In addition, if you delete a hosted 29 // zone, someone could hijack the domain and route traffic to their own resources 30 // using your domain name. 31 // 32 // If you want to avoid the monthly charge for the hosted zone, you can transfer 33 // DNS service for the domain to a free DNS service. When you transfer DNS service, 34 // you have to update the name servers for the domain registration. If the domain 35 // is registered with Route 53, see [UpdateDomainNameservers]for information about how to replace Route 53 36 // name servers with name servers for the new DNS service. If the domain is 37 // registered with another registrar, use the method provided by the registrar to 38 // update name servers for the domain registration. For more information, perform 39 // an internet search on "free DNS service." 40 // 41 // You can delete a hosted zone only if it contains only the default SOA and NS 42 // records and has DNSSEC signing disabled. If the hosted zone contains other 43 // records or has DNSSEC enabled, you must delete the records and disable DNSSEC 44 // before deletion. Attempting to delete a hosted zone with additional records or 45 // DNSSEC enabled returns a HostedZoneNotEmpty error. For information about 46 // deleting records, see [ChangeResourceRecordSets]. 47 // 48 // To verify that the hosted zone has been deleted, do one of the following: 49 // 50 // - Use the GetHostedZone action to request information about the hosted zone. 51 // 52 // - Use the ListHostedZones action to get a list of the hosted zones associated 53 // with the current Amazon Web Services account. 54 // 55 // [ChangeResourceRecordSets]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html 56 // [Deleting Public Hosted Zones That Were Created by Another Service]: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DeleteHostedZone.html#delete-public-hosted-zone-created-by-another-service 57 // [UpdateDomainNameservers]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_UpdateDomainNameservers.html 58 func (c *Client) DeleteHostedZone(ctx context.Context, params *DeleteHostedZoneInput, optFns ...func(*Options)) (*DeleteHostedZoneOutput, error) { 59 if params == nil { 60 params = &DeleteHostedZoneInput{} 61 } 62 63 result, metadata, err := c.invokeOperation(ctx, "DeleteHostedZone", params, optFns, c.addOperationDeleteHostedZoneMiddlewares) 64 if err != nil { 65 return nil, err 66 } 67 68 out := result.(*DeleteHostedZoneOutput) 69 out.ResultMetadata = metadata 70 return out, nil 71 } 72 73 // A request to delete a hosted zone. 74 type DeleteHostedZoneInput struct { 75 76 // The ID of the hosted zone you want to delete. 77 // 78 // This member is required. 79 Id *string 80 81 noSmithyDocumentSerde 82 } 83 84 // A complex type that contains the response to a DeleteHostedZone request. 85 type DeleteHostedZoneOutput struct { 86 87 // A complex type that contains the ID, the status, and the date and time of a 88 // request to delete a hosted zone. 89 // 90 // This member is required. 91 ChangeInfo *types.ChangeInfo 92 93 // Metadata pertaining to the operation's result. 94 ResultMetadata middleware.Metadata 95 96 noSmithyDocumentSerde 97 } 98 99 func (c *Client) addOperationDeleteHostedZoneMiddlewares(stack *middleware.Stack, options Options) (err error) { 100 err = stack.Serialize.Add(&awsRestxml_serializeOpDeleteHostedZone{}, middleware.After) 101 if err != nil { 102 return err 103 } 104 err = stack.Deserialize.Add(&awsRestxml_deserializeOpDeleteHostedZone{}, middleware.After) 105 if err != nil { 106 return err 107 } 108 109 if err = addComputeContentLength(stack); err != nil { 110 return err 111 } 112 if err = addResolveEndpointMiddleware(stack, options); err != nil { 113 return err 114 } 115 if err = addComputePayloadSHA256(stack); err != nil { 116 return err 117 } 118 if err = addRecordResponseTiming(stack, options); err != nil { 119 return err 120 } 121 if err = addCredentialSource(stack, options); err != nil { 122 return err 123 } 124 if err = addOpDeleteHostedZoneValidationMiddleware(stack); err != nil { 125 return err 126 } 127 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 128 return err 129 } 130 if err = addResponseErrorMiddleware(stack); err != nil { 131 return err 132 } 133 if err = addSanitizeURLMiddleware(stack); err != nil { 134 return err 135 } 136 if err = addRequestResponseLogging(stack, options); err != nil { 137 return err 138 } 139 if err = addDisableHTTPSMiddleware(stack, options); err != nil { 140 return err 141 } 142 if err = addInterceptors(stack, options); err != nil { 143 return err 144 } 145 return nil 146 }