/
database.ts
367 lines (361 loc) · 20.2 KB
/
database.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
import * as pulumi from "@pulumi/pulumi";
import * as utilities from "../utilities";
/**
* Allows you to manage an Azure SQL Database
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azure from "@pulumi/azure";
*
* const testResourceGroup = new azure.core.ResourceGroup("test", {
* location: "West US",
* name: "acceptanceTestResourceGroup1",
* });
* const testSqlServer = new azure.sql.SqlServer("test", {
* administratorLogin: "4dm1n157r470r",
* administratorLoginPassword: "4-v3ry-53cr37-p455w0rd",
* location: "West US",
* name: "mysqlserver",
* resourceGroupName: testResourceGroup.name,
* version: "12.0",
* });
* const testDatabase = new azure.sql.Database("test", {
* location: "West US",
* name: "mysqldatabase",
* resourceGroupName: testResourceGroup.name,
* serverName: testSqlServer.name,
* tags: {
* environment: "production",
* },
* });
* ```
*/
export class Database extends pulumi.CustomResource {
/**
* Get an existing Database resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
*/
public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: DatabaseState, opts?: pulumi.CustomResourceOptions): Database {
return new Database(name, <any>state, { ...opts, id: id });
}
/**
* The name of the collation. Applies only if `create_mode` is `Default`. Azure default is `SQL_LATIN1_GENERAL_CP1_CI_AS`. Changing this forces a new resource to be created.
*/
public readonly collation!: pulumi.Output<string>;
/**
* Specifies the type of database to create. Defaults to `Default`. See below for the accepted values/
*/
public readonly createMode!: pulumi.Output<string | undefined>;
/**
* The creation date of the SQL Database.
*/
public /*out*/ readonly creationDate!: pulumi.Output<string>;
/**
* The default secondary location of the SQL Database.
*/
public /*out*/ readonly defaultSecondaryLocation!: pulumi.Output<string>;
/**
* The edition of the database to be created. Applies only if `create_mode` is `Default`. Valid values are: `Basic`, `Standard`, `Premium`, or `DataWarehouse`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
public readonly edition!: pulumi.Output<string>;
/**
* The name of the elastic database pool.
*/
public readonly elasticPoolName!: pulumi.Output<string>;
public /*out*/ readonly encryption!: pulumi.Output<string>;
/**
* A Database Import block as documented below. `create_mode` must be set to `Default`.
*/
public readonly import!: pulumi.Output<{ administratorLogin: string, administratorLoginPassword: string, authenticationType: string, operationMode?: string, storageKey: string, storageKeyType: string, storageUri: string } | undefined>;
/**
* Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
*/
public readonly location!: pulumi.Output<string>;
/**
* The maximum size that the database can grow to. Applies only if `create_mode` is `Default`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
public readonly maxSizeBytes!: pulumi.Output<string>;
/**
* The name of the database.
*/
public readonly name!: pulumi.Output<string>;
/**
* Read-only connections will be redirected to a high-available replica. Please see [Use read-only replicas to load-balance read-only query workloads](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-read-scale-out).
*/
public readonly readScale!: pulumi.Output<boolean | undefined>;
/**
* Use `requested_service_objective_id` or `requested_service_objective_name` to set the performance level for the database.
* Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
public readonly requestedServiceObjectiveId!: pulumi.Output<string>;
/**
* Use `requested_service_objective_name` or `requested_service_objective_id` to set the performance level for the database. Valid values are: `S0`, `S1`, `S2`, `S3`, `P1`, `P2`, `P4`, `P6`, `P11` and `ElasticPool`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
public readonly requestedServiceObjectiveName!: pulumi.Output<string>;
/**
* The name of the resource group in which to create the database. This must be the same as Database Server resource group currently.
*/
public readonly resourceGroupName!: pulumi.Output<string>;
/**
* The point in time for the restore. Only applies if `create_mode` is `PointInTimeRestore` e.g. 2013-11-08T22:00:40Z
*/
public readonly restorePointInTime!: pulumi.Output<string>;
/**
* The name of the SQL Server on which to create the database.
*/
public readonly serverName!: pulumi.Output<string>;
/**
* The deletion date time of the source database. Only applies to deleted databases where `create_mode` is `PointInTimeRestore`.
*/
public readonly sourceDatabaseDeletionDate!: pulumi.Output<string>;
/**
* The URI of the source database if `create_mode` value is not `Default`.
*/
public readonly sourceDatabaseId!: pulumi.Output<string>;
/**
* A mapping of tags to assign to the resource.
*/
public readonly tags!: pulumi.Output<{[key: string]: any}>;
/**
* Threat detection policy configuration. The `threat_detection_policy` block supports fields documented below.
*/
public readonly threatDetectionPolicy!: pulumi.Output<{ disabledAlerts?: string[], emailAccountAdmins?: string, emailAddresses?: string[], retentionDays?: number, state?: string, storageAccountAccessKey?: string, storageEndpoint?: string, useServerDefault?: string }>;
/**
* Create a Database resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: DatabaseArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: DatabaseArgs | DatabaseState, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
if (opts && opts.id) {
const state = argsOrState as DatabaseState | undefined;
inputs["collation"] = state ? state.collation : undefined;
inputs["createMode"] = state ? state.createMode : undefined;
inputs["creationDate"] = state ? state.creationDate : undefined;
inputs["defaultSecondaryLocation"] = state ? state.defaultSecondaryLocation : undefined;
inputs["edition"] = state ? state.edition : undefined;
inputs["elasticPoolName"] = state ? state.elasticPoolName : undefined;
inputs["encryption"] = state ? state.encryption : undefined;
inputs["import"] = state ? state.import : undefined;
inputs["location"] = state ? state.location : undefined;
inputs["maxSizeBytes"] = state ? state.maxSizeBytes : undefined;
inputs["name"] = state ? state.name : undefined;
inputs["readScale"] = state ? state.readScale : undefined;
inputs["requestedServiceObjectiveId"] = state ? state.requestedServiceObjectiveId : undefined;
inputs["requestedServiceObjectiveName"] = state ? state.requestedServiceObjectiveName : undefined;
inputs["resourceGroupName"] = state ? state.resourceGroupName : undefined;
inputs["restorePointInTime"] = state ? state.restorePointInTime : undefined;
inputs["serverName"] = state ? state.serverName : undefined;
inputs["sourceDatabaseDeletionDate"] = state ? state.sourceDatabaseDeletionDate : undefined;
inputs["sourceDatabaseId"] = state ? state.sourceDatabaseId : undefined;
inputs["tags"] = state ? state.tags : undefined;
inputs["threatDetectionPolicy"] = state ? state.threatDetectionPolicy : undefined;
} else {
const args = argsOrState as DatabaseArgs | undefined;
if (!args || args.resourceGroupName === undefined) {
throw new Error("Missing required property 'resourceGroupName'");
}
if (!args || args.serverName === undefined) {
throw new Error("Missing required property 'serverName'");
}
inputs["collation"] = args ? args.collation : undefined;
inputs["createMode"] = args ? args.createMode : undefined;
inputs["edition"] = args ? args.edition : undefined;
inputs["elasticPoolName"] = args ? args.elasticPoolName : undefined;
inputs["import"] = args ? args.import : undefined;
inputs["location"] = args ? args.location : undefined;
inputs["maxSizeBytes"] = args ? args.maxSizeBytes : undefined;
inputs["name"] = args ? args.name : undefined;
inputs["readScale"] = args ? args.readScale : undefined;
inputs["requestedServiceObjectiveId"] = args ? args.requestedServiceObjectiveId : undefined;
inputs["requestedServiceObjectiveName"] = args ? args.requestedServiceObjectiveName : undefined;
inputs["resourceGroupName"] = args ? args.resourceGroupName : undefined;
inputs["restorePointInTime"] = args ? args.restorePointInTime : undefined;
inputs["serverName"] = args ? args.serverName : undefined;
inputs["sourceDatabaseDeletionDate"] = args ? args.sourceDatabaseDeletionDate : undefined;
inputs["sourceDatabaseId"] = args ? args.sourceDatabaseId : undefined;
inputs["tags"] = args ? args.tags : undefined;
inputs["threatDetectionPolicy"] = args ? args.threatDetectionPolicy : undefined;
inputs["creationDate"] = undefined /*out*/;
inputs["defaultSecondaryLocation"] = undefined /*out*/;
inputs["encryption"] = undefined /*out*/;
}
super("azure:sql/database:Database", name, inputs, opts);
}
}
/**
* Input properties used for looking up and filtering Database resources.
*/
export interface DatabaseState {
/**
* The name of the collation. Applies only if `create_mode` is `Default`. Azure default is `SQL_LATIN1_GENERAL_CP1_CI_AS`. Changing this forces a new resource to be created.
*/
readonly collation?: pulumi.Input<string>;
/**
* Specifies the type of database to create. Defaults to `Default`. See below for the accepted values/
*/
readonly createMode?: pulumi.Input<string>;
/**
* The creation date of the SQL Database.
*/
readonly creationDate?: pulumi.Input<string>;
/**
* The default secondary location of the SQL Database.
*/
readonly defaultSecondaryLocation?: pulumi.Input<string>;
/**
* The edition of the database to be created. Applies only if `create_mode` is `Default`. Valid values are: `Basic`, `Standard`, `Premium`, or `DataWarehouse`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
readonly edition?: pulumi.Input<string>;
/**
* The name of the elastic database pool.
*/
readonly elasticPoolName?: pulumi.Input<string>;
readonly encryption?: pulumi.Input<string>;
/**
* A Database Import block as documented below. `create_mode` must be set to `Default`.
*/
readonly import?: pulumi.Input<{ administratorLogin: pulumi.Input<string>, administratorLoginPassword: pulumi.Input<string>, authenticationType: pulumi.Input<string>, operationMode?: pulumi.Input<string>, storageKey: pulumi.Input<string>, storageKeyType: pulumi.Input<string>, storageUri: pulumi.Input<string> }>;
/**
* Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
*/
readonly location?: pulumi.Input<string>;
/**
* The maximum size that the database can grow to. Applies only if `create_mode` is `Default`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
readonly maxSizeBytes?: pulumi.Input<string>;
/**
* The name of the database.
*/
readonly name?: pulumi.Input<string>;
/**
* Read-only connections will be redirected to a high-available replica. Please see [Use read-only replicas to load-balance read-only query workloads](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-read-scale-out).
*/
readonly readScale?: pulumi.Input<boolean>;
/**
* Use `requested_service_objective_id` or `requested_service_objective_name` to set the performance level for the database.
* Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
readonly requestedServiceObjectiveId?: pulumi.Input<string>;
/**
* Use `requested_service_objective_name` or `requested_service_objective_id` to set the performance level for the database. Valid values are: `S0`, `S1`, `S2`, `S3`, `P1`, `P2`, `P4`, `P6`, `P11` and `ElasticPool`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
readonly requestedServiceObjectiveName?: pulumi.Input<string>;
/**
* The name of the resource group in which to create the database. This must be the same as Database Server resource group currently.
*/
readonly resourceGroupName?: pulumi.Input<string>;
/**
* The point in time for the restore. Only applies if `create_mode` is `PointInTimeRestore` e.g. 2013-11-08T22:00:40Z
*/
readonly restorePointInTime?: pulumi.Input<string>;
/**
* The name of the SQL Server on which to create the database.
*/
readonly serverName?: pulumi.Input<string>;
/**
* The deletion date time of the source database. Only applies to deleted databases where `create_mode` is `PointInTimeRestore`.
*/
readonly sourceDatabaseDeletionDate?: pulumi.Input<string>;
/**
* The URI of the source database if `create_mode` value is not `Default`.
*/
readonly sourceDatabaseId?: pulumi.Input<string>;
/**
* A mapping of tags to assign to the resource.
*/
readonly tags?: pulumi.Input<{[key: string]: any}>;
/**
* Threat detection policy configuration. The `threat_detection_policy` block supports fields documented below.
*/
readonly threatDetectionPolicy?: pulumi.Input<{ disabledAlerts?: pulumi.Input<pulumi.Input<string>[]>, emailAccountAdmins?: pulumi.Input<string>, emailAddresses?: pulumi.Input<pulumi.Input<string>[]>, retentionDays?: pulumi.Input<number>, state?: pulumi.Input<string>, storageAccountAccessKey?: pulumi.Input<string>, storageEndpoint?: pulumi.Input<string>, useServerDefault?: pulumi.Input<string> }>;
}
/**
* The set of arguments for constructing a Database resource.
*/
export interface DatabaseArgs {
/**
* The name of the collation. Applies only if `create_mode` is `Default`. Azure default is `SQL_LATIN1_GENERAL_CP1_CI_AS`. Changing this forces a new resource to be created.
*/
readonly collation?: pulumi.Input<string>;
/**
* Specifies the type of database to create. Defaults to `Default`. See below for the accepted values/
*/
readonly createMode?: pulumi.Input<string>;
/**
* The edition of the database to be created. Applies only if `create_mode` is `Default`. Valid values are: `Basic`, `Standard`, `Premium`, or `DataWarehouse`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
readonly edition?: pulumi.Input<string>;
/**
* The name of the elastic database pool.
*/
readonly elasticPoolName?: pulumi.Input<string>;
/**
* A Database Import block as documented below. `create_mode` must be set to `Default`.
*/
readonly import?: pulumi.Input<{ administratorLogin: pulumi.Input<string>, administratorLoginPassword: pulumi.Input<string>, authenticationType: pulumi.Input<string>, operationMode?: pulumi.Input<string>, storageKey: pulumi.Input<string>, storageKeyType: pulumi.Input<string>, storageUri: pulumi.Input<string> }>;
/**
* Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
*/
readonly location?: pulumi.Input<string>;
/**
* The maximum size that the database can grow to. Applies only if `create_mode` is `Default`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
readonly maxSizeBytes?: pulumi.Input<string>;
/**
* The name of the database.
*/
readonly name?: pulumi.Input<string>;
/**
* Read-only connections will be redirected to a high-available replica. Please see [Use read-only replicas to load-balance read-only query workloads](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-read-scale-out).
*/
readonly readScale?: pulumi.Input<boolean>;
/**
* Use `requested_service_objective_id` or `requested_service_objective_name` to set the performance level for the database.
* Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
readonly requestedServiceObjectiveId?: pulumi.Input<string>;
/**
* Use `requested_service_objective_name` or `requested_service_objective_id` to set the performance level for the database. Valid values are: `S0`, `S1`, `S2`, `S3`, `P1`, `P2`, `P4`, `P6`, `P11` and `ElasticPool`. Please see [Azure SQL Database Service Tiers](https://azure.microsoft.com/en-gb/documentation/articles/sql-database-service-tiers/).
*/
readonly requestedServiceObjectiveName?: pulumi.Input<string>;
/**
* The name of the resource group in which to create the database. This must be the same as Database Server resource group currently.
*/
readonly resourceGroupName: pulumi.Input<string>;
/**
* The point in time for the restore. Only applies if `create_mode` is `PointInTimeRestore` e.g. 2013-11-08T22:00:40Z
*/
readonly restorePointInTime?: pulumi.Input<string>;
/**
* The name of the SQL Server on which to create the database.
*/
readonly serverName: pulumi.Input<string>;
/**
* The deletion date time of the source database. Only applies to deleted databases where `create_mode` is `PointInTimeRestore`.
*/
readonly sourceDatabaseDeletionDate?: pulumi.Input<string>;
/**
* The URI of the source database if `create_mode` value is not `Default`.
*/
readonly sourceDatabaseId?: pulumi.Input<string>;
/**
* A mapping of tags to assign to the resource.
*/
readonly tags?: pulumi.Input<{[key: string]: any}>;
/**
* Threat detection policy configuration. The `threat_detection_policy` block supports fields documented below.
*/
readonly threatDetectionPolicy?: pulumi.Input<{ disabledAlerts?: pulumi.Input<pulumi.Input<string>[]>, emailAccountAdmins?: pulumi.Input<string>, emailAddresses?: pulumi.Input<pulumi.Input<string>[]>, retentionDays?: pulumi.Input<number>, state?: pulumi.Input<string>, storageAccountAccessKey?: pulumi.Input<string>, storageEndpoint?: pulumi.Input<string>, useServerDefault?: pulumi.Input<string> }>;
}