1 // Code generated by smithy-go-codegen DO NOT EDIT.
2 3 package route53
4 5 import (
6 "context"
7 "fmt"
8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9 "github.com/aws/aws-sdk-go-v2/service/route53/types"
10 "github.com/aws/smithy-go/middleware"
11 smithyhttp "github.com/aws/smithy-go/transport/http"
12 )
13 14 // Deletes a hosted zone.
15 //
16 // 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
17 // the Amazon Route 53 Developer Guide for information about how to delete it. (The
18 // process is the same for public and private hosted zones that were created by
19 // another service.)
20 //
21 // If you want to keep your domain registration but you want to stop routing
22 // internet traffic to your website or web application, we recommend that you
23 // delete resource record sets in the hosted zone instead of deleting the hosted
24 // zone.
25 //
26 // If you delete a hosted zone, you can't undelete it. You must create a new
27 // hosted zone and update the name servers for your domain registration, which can
28 // require up to 48 hours to take effect. (If you delegated responsibility for a
29 // subdomain to a hosted zone and you delete the child hosted zone, you must update
30 // the name servers in the parent hosted zone.) In addition, if you delete a hosted
31 // zone, someone could hijack the domain and route traffic to their own resources
32 // using your domain name.
33 //
34 // If you want to avoid the monthly charge for the hosted zone, you can transfer
35 // DNS service for the domain to a free DNS service. When you transfer DNS service,
36 // you have to update the name servers for the domain registration. If the domain
37 // is registered with Route 53, see [UpdateDomainNameservers]for information about how to replace Route 53
38 // name servers with name servers for the new DNS service. If the domain is
39 // registered with another registrar, use the method provided by the registrar to
40 // update name servers for the domain registration. For more information, perform
41 // an internet search on "free DNS service."
42 //
43 // You can delete a hosted zone only if it contains only the default SOA and NS
44 // records and has DNSSEC signing disabled. If the hosted zone contains other
45 // records or has DNSSEC enabled, you must delete the records and disable DNSSEC
46 // before deletion. Attempting to delete a hosted zone with additional records or
47 // DNSSEC enabled returns a HostedZoneNotEmpty error. For information about
48 // deleting records, see [ChangeResourceRecordSets].
49 //
50 // To verify that the hosted zone has been deleted, do one of the following:
51 //
52 // - Use the GetHostedZone action to request information about the hosted zone.
53 //
54 // - Use the ListHostedZones action to get a list of the hosted zones associated
55 // with the current Amazon Web Services account.
56 //
57 // [ChangeResourceRecordSets]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html
58 // [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
59 // [UpdateDomainNameservers]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_UpdateDomainNameservers.html
60 func (c *Client) DeleteHostedZone(ctx context.Context, params *DeleteHostedZoneInput, optFns ...func(*Options)) (*DeleteHostedZoneOutput, error) {
61 if params == nil {
62 params = &DeleteHostedZoneInput{}
63 }
64 65 result, metadata, err := c.invokeOperation(ctx, "DeleteHostedZone", params, optFns, c.addOperationDeleteHostedZoneMiddlewares)
66 if err != nil {
67 return nil, err
68 }
69 70 out := result.(*DeleteHostedZoneOutput)
71 out.ResultMetadata = metadata
72 return out, nil
73 }
74 75 // A request to delete a hosted zone.
76 type DeleteHostedZoneInput struct {
77 78 // The ID of the hosted zone you want to delete.
79 //
80 // This member is required.
81 Id *string
82 83 noSmithyDocumentSerde
84 }
85 86 // A complex type that contains the response to a DeleteHostedZone request.
87 type DeleteHostedZoneOutput struct {
88 89 // A complex type that contains the ID, the status, and the date and time of a
90 // request to delete a hosted zone.
91 //
92 // This member is required.
93 ChangeInfo *types.ChangeInfo
94 95 // Metadata pertaining to the operation's result.
96 ResultMetadata middleware.Metadata
97 98 noSmithyDocumentSerde
99 }
100 101 func (c *Client) addOperationDeleteHostedZoneMiddlewares(stack *middleware.Stack, options Options) (err error) {
102 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
103 return err
104 }
105 err = stack.Serialize.Add(&awsRestxml_serializeOpDeleteHostedZone{}, middleware.After)
106 if err != nil {
107 return err
108 }
109 err = stack.Deserialize.Add(&awsRestxml_deserializeOpDeleteHostedZone{}, middleware.After)
110 if err != nil {
111 return err
112 }
113 if err := addProtocolFinalizerMiddlewares(stack, options, "DeleteHostedZone"); err != nil {
114 return fmt.Errorf("add protocol finalizers: %v", err)
115 }
116 117 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
118 return err
119 }
120 if err = addSetLoggerMiddleware(stack, options); err != nil {
121 return err
122 }
123 if err = addClientRequestID(stack); err != nil {
124 return err
125 }
126 if err = addComputeContentLength(stack); err != nil {
127 return err
128 }
129 if err = addResolveEndpointMiddleware(stack, options); err != nil {
130 return err
131 }
132 if err = addComputePayloadSHA256(stack); err != nil {
133 return err
134 }
135 if err = addRetry(stack, options); err != nil {
136 return err
137 }
138 if err = addRawResponseToMetadata(stack); err != nil {
139 return err
140 }
141 if err = addRecordResponseTiming(stack); err != nil {
142 return err
143 }
144 if err = addSpanRetryLoop(stack, options); err != nil {
145 return err
146 }
147 if err = addClientUserAgent(stack, options); err != nil {
148 return err
149 }
150 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
151 return err
152 }
153 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
154 return err
155 }
156 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
157 return err
158 }
159 if err = addTimeOffsetBuild(stack, c); err != nil {
160 return err
161 }
162 if err = addUserAgentRetryMode(stack, options); err != nil {
163 return err
164 }
165 if err = addCredentialSource(stack, options); err != nil {
166 return err
167 }
168 if err = addOpDeleteHostedZoneValidationMiddleware(stack); err != nil {
169 return err
170 }
171 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteHostedZone(options.Region), middleware.Before); err != nil {
172 return err
173 }
174 if err = addRecursionDetection(stack); err != nil {
175 return err
176 }
177 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
178 return err
179 }
180 if err = addResponseErrorMiddleware(stack); err != nil {
181 return err
182 }
183 if err = addSanitizeURLMiddleware(stack); err != nil {
184 return err
185 }
186 if err = addRequestResponseLogging(stack, options); err != nil {
187 return err
188 }
189 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
190 return err
191 }
192 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
193 return err
194 }
195 if err = addInterceptAttempt(stack, options); err != nil {
196 return err
197 }
198 if err = addInterceptors(stack, options); err != nil {
199 return err
200 }
201 return nil
202 }
203 204 func newServiceMetadataMiddleware_opDeleteHostedZone(region string) *awsmiddleware.RegisterServiceMetadata {
205 return &awsmiddleware.RegisterServiceMetadata{
206 Region: region,
207 ServiceID: ServiceID,
208 OperationName: "DeleteHostedZone",
209 }
210 }
211