1 // Code generated by smithy-go-codegen DO NOT EDIT.
2 3 package lightsail
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/lightsail/types"
10 "github.com/aws/smithy-go/middleware"
11 smithyhttp "github.com/aws/smithy-go/transport/http"
12 )
13 14 // Creates a new database in Amazon Lightsail.
15 //
16 // The create relational database operation supports tag-based access control via
17 // request tags. For more information, see the [Amazon Lightsail Developer Guide].
18 //
19 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags
20 func (c *Client) CreateRelationalDatabase(ctx context.Context, params *CreateRelationalDatabaseInput, optFns ...func(*Options)) (*CreateRelationalDatabaseOutput, error) {
21 if params == nil {
22 params = &CreateRelationalDatabaseInput{}
23 }
24 25 result, metadata, err := c.invokeOperation(ctx, "CreateRelationalDatabase", params, optFns, c.addOperationCreateRelationalDatabaseMiddlewares)
26 if err != nil {
27 return nil, err
28 }
29 30 out := result.(*CreateRelationalDatabaseOutput)
31 out.ResultMetadata = metadata
32 return out, nil
33 }
34 35 type CreateRelationalDatabaseInput struct {
36 37 // The meaning of this parameter differs according to the database engine you use.
38 //
39 // MySQL
40 //
41 // The name of the database to create when the Lightsail database resource is
42 // created. If this parameter isn't specified, no database is created in the
43 // database resource.
44 //
45 // Constraints:
46 //
47 // - Must contain 1 to 64 letters or numbers.
48 //
49 // - Must begin with a letter. Subsequent characters can be letters,
50 // underscores, or digits (0- 9).
51 //
52 // - Can't be a word reserved by the specified database engine.
53 //
54 // For more information about reserved words in MySQL, see the Keywords and
55 // Reserved Words articles for [MySQL 5.6], [MySQL 5.7], and [MySQL 8.0].
56 //
57 // PostgreSQL
58 //
59 // The name of the database to create when the Lightsail database resource is
60 // created. If this parameter isn't specified, a database named postgres is
61 // created in the database resource.
62 //
63 // Constraints:
64 //
65 // - Must contain 1 to 63 letters or numbers.
66 //
67 // - Must begin with a letter. Subsequent characters can be letters,
68 // underscores, or digits (0- 9).
69 //
70 // - Can't be a word reserved by the specified database engine.
71 //
72 // For more information about reserved words in PostgreSQL, see the SQL Key Words
73 // articles for [PostgreSQL 9.6], [PostgreSQL 10], [PostgreSQL 11], and [PostgreSQL 12].
74 //
75 // [MySQL 5.6]: https://dev.mysql.com/doc/refman/5.6/en/keywords.html
76 // [PostgreSQL 9.6]: https://www.postgresql.org/docs/9.6/sql-keywords-appendix.html
77 // [PostgreSQL 10]: https://www.postgresql.org/docs/10/sql-keywords-appendix.html
78 // [MySQL 8.0]: https://dev.mysql.com/doc/refman/8.0/en/keywords.html
79 // [PostgreSQL 12]: https://www.postgresql.org/docs/12/sql-keywords-appendix.html
80 // [PostgreSQL 11]: https://www.postgresql.org/docs/11/sql-keywords-appendix.html
81 // [MySQL 5.7]: https://dev.mysql.com/doc/refman/5.7/en/keywords.html
82 //
83 // This member is required.
84 MasterDatabaseName *string
85 86 // The name for the master user.
87 //
88 // MySQL
89 //
90 // Constraints:
91 //
92 // - Required for MySQL.
93 //
94 // - Must be 1 to 16 letters or numbers. Can contain underscores.
95 //
96 // - First character must be a letter.
97 //
98 // - Can't be a reserved word for the chosen database engine.
99 //
100 // For more information about reserved words in MySQL 5.6 or 5.7, see the Keywords
101 // and Reserved Words articles for [MySQL 5.6], [MySQL 5.7], or [MySQL 8.0].
102 //
103 // PostgreSQL
104 //
105 // Constraints:
106 //
107 // - Required for PostgreSQL.
108 //
109 // - Must be 1 to 63 letters or numbers. Can contain underscores.
110 //
111 // - First character must be a letter.
112 //
113 // - Can't be a reserved word for the chosen database engine.
114 //
115 // For more information about reserved words in MySQL 5.6 or 5.7, see the Keywords
116 // and Reserved Words articles for [PostgreSQL 9.6], [PostgreSQL 10], [PostgreSQL 11], and [PostgreSQL 12].
117 //
118 // [MySQL 5.6]: https://dev.mysql.com/doc/refman/5.6/en/keywords.html
119 // [PostgreSQL 9.6]: https://www.postgresql.org/docs/9.6/sql-keywords-appendix.html
120 // [PostgreSQL 10]: https://www.postgresql.org/docs/10/sql-keywords-appendix.html
121 // [MySQL 8.0]: https://dev.mysql.com/doc/refman/8.0/en/keywords.html
122 // [PostgreSQL 12]: https://www.postgresql.org/docs/12/sql-keywords-appendix.html
123 // [PostgreSQL 11]: https://www.postgresql.org/docs/11/sql-keywords-appendix.html
124 // [MySQL 5.7]: https://dev.mysql.com/doc/refman/5.7/en/keywords.html
125 //
126 // This member is required.
127 MasterUsername *string
128 129 // The blueprint ID for your new database. A blueprint describes the major engine
130 // version of a database.
131 //
132 // You can get a list of database blueprints IDs by using the get relational
133 // database blueprints operation.
134 //
135 // This member is required.
136 RelationalDatabaseBlueprintId *string
137 138 // The bundle ID for your new database. A bundle describes the performance
139 // specifications for your database.
140 //
141 // You can get a list of database bundle IDs by using the get relational database
142 // bundles operation.
143 //
144 // This member is required.
145 RelationalDatabaseBundleId *string
146 147 // The name to use for your new Lightsail database resource.
148 //
149 // Constraints:
150 //
151 // - Must contain from 2 to 255 alphanumeric characters, or hyphens.
152 //
153 // - The first and last character must be a letter or number.
154 //
155 // This member is required.
156 RelationalDatabaseName *string
157 158 // The Availability Zone in which to create your new database. Use the us-east-2a
159 // case-sensitive format.
160 //
161 // You can get a list of Availability Zones by using the get regions operation. Be
162 // sure to add the include relational database Availability Zones parameter to
163 // your request.
164 AvailabilityZone *string
165 166 // The password for the master user. The password can include any printable ASCII
167 // character except "/", """, or "@". It cannot contain spaces.
168 //
169 // MySQL
170 //
171 // Constraints: Must contain from 8 to 41 characters.
172 //
173 // PostgreSQL
174 //
175 // Constraints: Must contain from 8 to 128 characters.
176 MasterUserPassword *string
177 178 // The daily time range during which automated backups are created for your new
179 // database if automated backups are enabled.
180 //
181 // The default is a 30-minute window selected at random from an 8-hour block of
182 // time for each AWS Region. For more information about the preferred backup window
183 // time blocks for each region, see the [Working With Backups]guide in the Amazon Relational Database
184 // Service documentation.
185 //
186 // Constraints:
187 //
188 // - Must be in the hh24:mi-hh24:mi format.
189 //
190 // Example: 16:00-16:30
191 //
192 // - Specified in Coordinated Universal Time (UTC).
193 //
194 // - Must not conflict with the preferred maintenance window.
195 //
196 // - Must be at least 30 minutes.
197 //
198 // [Working With Backups]: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html#USER_WorkingWithAutomatedBackups.BackupWindow
199 PreferredBackupWindow *string
200 201 // The weekly time range during which system maintenance can occur on your new
202 // database.
203 //
204 // The default is a 30-minute window selected at random from an 8-hour block of
205 // time for each AWS Region, occurring on a random day of the week.
206 //
207 // Constraints:
208 //
209 // - Must be in the ddd:hh24:mi-ddd:hh24:mi format.
210 //
211 // - Valid days: Mon, Tue, Wed, Thu, Fri, Sat, Sun.
212 //
213 // - Must be at least 30 minutes.
214 //
215 // - Specified in Coordinated Universal Time (UTC).
216 //
217 // - Example: Tue:17:00-Tue:17:30
218 PreferredMaintenanceWindow *string
219 220 // Specifies the accessibility options for your new database. A value of true
221 // specifies a database that is available to resources outside of your Lightsail
222 // account. A value of false specifies a database that is available only to your
223 // Lightsail resources in the same region as your database.
224 PubliclyAccessible *bool
225 226 // The tag keys and optional values to add to the resource during create.
227 //
228 // Use the TagResource action to tag a resource after it's created.
229 Tags []types.Tag
230 231 noSmithyDocumentSerde
232 }
233 234 type CreateRelationalDatabaseOutput struct {
235 236 // An array of objects that describe the result of the action, such as the status
237 // of the request, the timestamp of the request, and the resources affected by the
238 // request.
239 Operations []types.Operation
240 241 // Metadata pertaining to the operation's result.
242 ResultMetadata middleware.Metadata
243 244 noSmithyDocumentSerde
245 }
246 247 func (c *Client) addOperationCreateRelationalDatabaseMiddlewares(stack *middleware.Stack, options Options) (err error) {
248 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
249 return err
250 }
251 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateRelationalDatabase{}, middleware.After)
252 if err != nil {
253 return err
254 }
255 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateRelationalDatabase{}, middleware.After)
256 if err != nil {
257 return err
258 }
259 if err := addProtocolFinalizerMiddlewares(stack, options, "CreateRelationalDatabase"); err != nil {
260 return fmt.Errorf("add protocol finalizers: %v", err)
261 }
262 263 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
264 return err
265 }
266 if err = addSetLoggerMiddleware(stack, options); err != nil {
267 return err
268 }
269 if err = addClientRequestID(stack); err != nil {
270 return err
271 }
272 if err = addComputeContentLength(stack); err != nil {
273 return err
274 }
275 if err = addResolveEndpointMiddleware(stack, options); err != nil {
276 return err
277 }
278 if err = addComputePayloadSHA256(stack); err != nil {
279 return err
280 }
281 if err = addRetry(stack, options); err != nil {
282 return err
283 }
284 if err = addRawResponseToMetadata(stack); err != nil {
285 return err
286 }
287 if err = addRecordResponseTiming(stack); err != nil {
288 return err
289 }
290 if err = addSpanRetryLoop(stack, options); err != nil {
291 return err
292 }
293 if err = addClientUserAgent(stack, options); err != nil {
294 return err
295 }
296 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
297 return err
298 }
299 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
300 return err
301 }
302 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
303 return err
304 }
305 if err = addTimeOffsetBuild(stack, c); err != nil {
306 return err
307 }
308 if err = addUserAgentRetryMode(stack, options); err != nil {
309 return err
310 }
311 if err = addCredentialSource(stack, options); err != nil {
312 return err
313 }
314 if err = addOpCreateRelationalDatabaseValidationMiddleware(stack); err != nil {
315 return err
316 }
317 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateRelationalDatabase(options.Region), middleware.Before); err != nil {
318 return err
319 }
320 if err = addRecursionDetection(stack); err != nil {
321 return err
322 }
323 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
324 return err
325 }
326 if err = addResponseErrorMiddleware(stack); err != nil {
327 return err
328 }
329 if err = addRequestResponseLogging(stack, options); err != nil {
330 return err
331 }
332 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
333 return err
334 }
335 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
336 return err
337 }
338 if err = addInterceptAttempt(stack, options); err != nil {
339 return err
340 }
341 if err = addInterceptors(stack, options); err != nil {
342 return err
343 }
344 return nil
345 }
346 347 func newServiceMetadataMiddleware_opCreateRelationalDatabase(region string) *awsmiddleware.RegisterServiceMetadata {
348 return &awsmiddleware.RegisterServiceMetadata{
349 Region: region,
350 ServiceID: ServiceID,
351 OperationName: "CreateRelationalDatabase",
352 }
353 }
354