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 // Creates a new public or private hosted zone. You create records in a public
15 // hosted zone to define how you want to route traffic on the internet for a
16 // domain, such as example.com, and its subdomains (apex.example.com,
17 // acme.example.com). You create records in a private hosted zone to define how you
18 // want to route traffic for a domain and its subdomains within one or more Amazon
19 // Virtual Private Clouds (Amazon VPCs).
20 //
21 // You can't convert a public hosted zone to a private hosted zone or vice versa.
22 // Instead, you must create a new hosted zone with the same name and create new
23 // resource record sets.
24 //
25 // For more information about charges for hosted zones, see [Amazon Route 53 Pricing].
26 //
27 // Note the following:
28 //
29 // - You can't create a hosted zone for a top-level domain (TLD) such as .com.
30 //
31 // - For public hosted zones, Route 53 automatically creates a default SOA
32 // record and four NS records for the zone. For more information about SOA and NS
33 // records, see [NS and SOA Records that Route 53 Creates for a Hosted Zone]in the Amazon Route 53 Developer Guide.
34 //
35 // If you want to use the same name servers for multiple public hosted zones, you
36 //
37 // can optionally associate a reusable delegation set with the hosted zone. See the
38 // DelegationSetId element.
39 //
40 // - If your domain is registered with a registrar other than Route 53, you must
41 // update the name servers with your registrar to make Route 53 the DNS service for
42 // the domain. For more information, see [Migrating DNS Service for an Existing Domain to Amazon Route 53]in the Amazon Route 53 Developer Guide.
43 //
44 // When you submit a CreateHostedZone request, the initial status of the hosted
45 // zone is PENDING . For public hosted zones, this means that the NS and SOA
46 // records are not yet available on all Route 53 DNS servers. When the NS and SOA
47 // records are available, the status of the zone changes to INSYNC .
48 //
49 // The CreateHostedZone request requires the caller to have an ec2:DescribeVpcs
50 // permission.
51 //
52 // When creating private hosted zones, the Amazon VPC must belong to the same
53 // partition where the hosted zone is created. A partition is a group of Amazon Web
54 // Services Regions. Each Amazon Web Services account is scoped to one partition.
55 //
56 // The following are the supported partitions:
57 //
58 // - aws - Amazon Web Services Regions
59 //
60 // - aws-cn - China Regions
61 //
62 // - aws-us-gov - Amazon Web Services GovCloud (US) Region
63 //
64 // For more information, see [Access Management] in the Amazon Web Services General Reference.
65 //
66 // [Access Management]: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
67 // [NS and SOA Records that Route 53 Creates for a Hosted Zone]: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/SOA-NSrecords.html
68 // [Amazon Route 53 Pricing]: http://aws.amazon.com/route53/pricing/
69 //
70 // [Migrating DNS Service for an Existing Domain to Amazon Route 53]: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/MigratingDNS.html
71 func (c *Client) CreateHostedZone(ctx context.Context, params *CreateHostedZoneInput, optFns ...func(*Options)) (*CreateHostedZoneOutput, error) {
72 if params == nil {
73 params = &CreateHostedZoneInput{}
74 }
75 76 result, metadata, err := c.invokeOperation(ctx, "CreateHostedZone", params, optFns, c.addOperationCreateHostedZoneMiddlewares)
77 if err != nil {
78 return nil, err
79 }
80 81 out := result.(*CreateHostedZoneOutput)
82 out.ResultMetadata = metadata
83 return out, nil
84 }
85 86 // A complex type that contains information about the request to create a public
87 // or private hosted zone.
88 type CreateHostedZoneInput struct {
89 90 // A unique string that identifies the request and that allows failed
91 // CreateHostedZone requests to be retried without the risk of executing the
92 // operation twice. You must use a unique CallerReference string every time you
93 // submit a CreateHostedZone request. CallerReference can be any unique string,
94 // for example, a date/time stamp.
95 //
96 // This member is required.
97 CallerReference *string
98 99 // The name of the domain. Specify a fully qualified domain name, for example,
100 // www.example.com. The trailing dot is optional; Amazon Route 53 assumes that the
101 // domain name is fully qualified. This means that Route 53 treats www.example.com
102 // (without a trailing dot) and www.example.com. (with a trailing dot) as
103 // identical.
104 //
105 // If you're creating a public hosted zone, this is the name you have registered
106 // with your DNS registrar. If your domain name is registered with a registrar
107 // other than Route 53, change the name servers for your domain to the set of
108 // NameServers that CreateHostedZone returns in DelegationSet .
109 //
110 // This member is required.
111 Name *string
112 113 // If you want to associate a reusable delegation set with this hosted zone, the
114 // ID that Amazon Route 53 assigned to the reusable delegation set when you created
115 // it. For more information about reusable delegation sets, see [CreateReusableDelegationSet].
116 //
117 // If you are using a reusable delegation set to create a public hosted zone for a
118 // subdomain, make sure that the parent hosted zone doesn't use one or more of the
119 // same name servers. If you have overlapping nameservers, the operation will cause
120 // a ConflictingDomainsExist error.
121 //
122 // [CreateReusableDelegationSet]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateReusableDelegationSet.html
123 DelegationSetId *string
124 125 // (Optional) A complex type that contains the following optional values:
126 //
127 // - For public and private hosted zones, an optional comment
128 //
129 // - For private hosted zones, an optional PrivateZone element
130 //
131 // If you don't specify a comment or the PrivateZone element, omit HostedZoneConfig
132 // and the other elements.
133 HostedZoneConfig *types.HostedZoneConfig
134 135 // (Private hosted zones only) A complex type that contains information about the
136 // Amazon VPC that you're associating with this hosted zone.
137 //
138 // You can specify only one Amazon VPC when you create a private hosted zone. If
139 // you are associating a VPC with a hosted zone with this request, the paramaters
140 // VPCId and VPCRegion are also required.
141 //
142 // To associate additional Amazon VPCs with the hosted zone, use [AssociateVPCWithHostedZone] after you create
143 // a hosted zone.
144 //
145 // [AssociateVPCWithHostedZone]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_AssociateVPCWithHostedZone.html
146 VPC *types.VPC
147 148 noSmithyDocumentSerde
149 }
150 151 // A complex type containing the response information for the hosted zone.
152 type CreateHostedZoneOutput struct {
153 154 // A complex type that contains information about the CreateHostedZone request.
155 //
156 // This member is required.
157 ChangeInfo *types.ChangeInfo
158 159 // A complex type that describes the name servers for this hosted zone.
160 //
161 // This member is required.
162 DelegationSet *types.DelegationSet
163 164 // A complex type that contains general information about the hosted zone.
165 //
166 // This member is required.
167 HostedZone *types.HostedZone
168 169 // The unique URL representing the new hosted zone.
170 //
171 // This member is required.
172 Location *string
173 174 // A complex type that contains information about an Amazon VPC that you
175 // associated with this hosted zone.
176 VPC *types.VPC
177 178 // Metadata pertaining to the operation's result.
179 ResultMetadata middleware.Metadata
180 181 noSmithyDocumentSerde
182 }
183 184 func (c *Client) addOperationCreateHostedZoneMiddlewares(stack *middleware.Stack, options Options) (err error) {
185 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
186 return err
187 }
188 err = stack.Serialize.Add(&awsRestxml_serializeOpCreateHostedZone{}, middleware.After)
189 if err != nil {
190 return err
191 }
192 err = stack.Deserialize.Add(&awsRestxml_deserializeOpCreateHostedZone{}, middleware.After)
193 if err != nil {
194 return err
195 }
196 if err := addProtocolFinalizerMiddlewares(stack, options, "CreateHostedZone"); err != nil {
197 return fmt.Errorf("add protocol finalizers: %v", err)
198 }
199 200 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
201 return err
202 }
203 if err = addSetLoggerMiddleware(stack, options); err != nil {
204 return err
205 }
206 if err = addClientRequestID(stack); err != nil {
207 return err
208 }
209 if err = addComputeContentLength(stack); err != nil {
210 return err
211 }
212 if err = addResolveEndpointMiddleware(stack, options); err != nil {
213 return err
214 }
215 if err = addComputePayloadSHA256(stack); err != nil {
216 return err
217 }
218 if err = addRetry(stack, options); err != nil {
219 return err
220 }
221 if err = addRawResponseToMetadata(stack); err != nil {
222 return err
223 }
224 if err = addRecordResponseTiming(stack); err != nil {
225 return err
226 }
227 if err = addSpanRetryLoop(stack, options); err != nil {
228 return err
229 }
230 if err = addClientUserAgent(stack, options); err != nil {
231 return err
232 }
233 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
234 return err
235 }
236 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
237 return err
238 }
239 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
240 return err
241 }
242 if err = addTimeOffsetBuild(stack, c); err != nil {
243 return err
244 }
245 if err = addUserAgentRetryMode(stack, options); err != nil {
246 return err
247 }
248 if err = addCredentialSource(stack, options); err != nil {
249 return err
250 }
251 if err = addOpCreateHostedZoneValidationMiddleware(stack); err != nil {
252 return err
253 }
254 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateHostedZone(options.Region), middleware.Before); err != nil {
255 return err
256 }
257 if err = addRecursionDetection(stack); err != nil {
258 return err
259 }
260 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
261 return err
262 }
263 if err = addResponseErrorMiddleware(stack); err != nil {
264 return err
265 }
266 if err = addSanitizeURLMiddleware(stack); err != nil {
267 return err
268 }
269 if err = addRequestResponseLogging(stack, options); err != nil {
270 return err
271 }
272 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
273 return err
274 }
275 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
276 return err
277 }
278 if err = addInterceptAttempt(stack, options); err != nil {
279 return err
280 }
281 if err = addInterceptors(stack, options); err != nil {
282 return err
283 }
284 return nil
285 }
286 287 func newServiceMetadataMiddleware_opCreateHostedZone(region string) *awsmiddleware.RegisterServiceMetadata {
288 return &awsmiddleware.RegisterServiceMetadata{
289 Region: region,
290 ServiceID: ServiceID,
291 OperationName: "CreateHostedZone",
292 }
293 }
294