/
databaseInstance.go
704 lines (643 loc) · 34.9 KB
/
databaseInstance.go
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
// *** 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! ***
package sql
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Creates a new Google SQL Database Instance. For more information, see the [official documentation](https://cloud.google.com/sql/),
// or the [JSON API](https://cloud.google.com/sql/docs/admin-api/v1beta4/instances).
//
// > **NOTE on `sql.DatabaseInstance`:** - First-generation instances have been
// deprecated and should no longer be created, see [upgrade docs](https://cloud.google.com/sql/docs/mysql/upgrade-2nd-gen)
// for more details.
// To upgrade your First-generation instance, update your config that the instance has
// * `settings.ip_configuration.ipv4_enabled=true`
// * `settings.backup_configuration.enabled=true`
// * `settings.backup_configuration.binary_log_enabled=true`.\
// Apply the config, then upgrade the instance in the console as described in the documentation.
// Once upgraded, update the following attributes in your config to the correct value according to
// the above documentation:
// * `region`
// * `databaseVersion` (if applicable)
// * `tier`
// Remove any fields that are not applicable to Second-generation instances:
// * `settings.crash_safe_replication`
// * `settings.replication_type`
// * `settings.authorized_gae_applications`
// And change values to appropriate values for Second-generation instances for:
// * `activationPolicy` ("ON_DEMAND" is no longer an option)
// * `pricingPlan` ("PER_USE" is now the only valid option)
// Change `settings.backup_configuration.enabled` attribute back to its desired value and apply as necessary.
//
// > **NOTE on `sql.DatabaseInstance`:** - Second-generation instances include a
// default 'root'@'%' user with no password. This user will be deleted by the provider on
// instance creation. You should use `sql.User` to define a custom user with
// a restricted host and strong password.
//
// > **Note**: On newer versions of the provider, you must explicitly set `deletion_protection=false`
// (and run `pulumi update` to write the field to state) in order to destroy an instance.
// It is recommended to not set this field (or set it to true) until you're ready to destroy the instance and its databases.
//
// ## Example Usage
// ### SQL Second Generation Instance
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-gcp/sdk/v5/go/gcp/sql"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := sql.NewDatabaseInstance(ctx, "master", &sql.DatabaseInstanceArgs{
// DatabaseVersion: pulumi.String("POSTGRES_11"),
// Region: pulumi.String("us-central1"),
// Settings: &sql.DatabaseInstanceSettingsArgs{
// Tier: pulumi.String("db-f1-micro"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Private IP Instance
// > **NOTE:** For private IP instance setup, note that the `sql.DatabaseInstance` does not actually interpolate values from `servicenetworking.Connection`. You must explicitly add a `dependsOn`reference as shown below.
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-gcp/sdk/v5/go/gcp/compute"
// "github.com/pulumi/pulumi-gcp/sdk/v5/go/gcp/servicenetworking"
// "github.com/pulumi/pulumi-gcp/sdk/v5/go/gcp/sql"
// "github.com/pulumi/pulumi-random/sdk/v4/go/random"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// privateNetwork, err := compute.NewNetwork(ctx, "privateNetwork", nil, pulumi.Provider(google_beta))
// if err != nil {
// return err
// }
// privateIpAddress, err := compute.NewGlobalAddress(ctx, "privateIpAddress", &compute.GlobalAddressArgs{
// Purpose: pulumi.String("VPC_PEERING"),
// AddressType: pulumi.String("INTERNAL"),
// PrefixLength: pulumi.Int(16),
// Network: privateNetwork.ID(),
// }, pulumi.Provider(google_beta))
// if err != nil {
// return err
// }
// privateVpcConnection, err := servicenetworking.NewConnection(ctx, "privateVpcConnection", &servicenetworking.ConnectionArgs{
// Network: privateNetwork.ID(),
// Service: pulumi.String("servicenetworking.googleapis.com"),
// ReservedPeeringRanges: pulumi.StringArray{
// privateIpAddress.Name,
// },
// }, pulumi.Provider(google_beta))
// if err != nil {
// return err
// }
// _, err = random.NewRandomId(ctx, "dbNameSuffix", &random.RandomIdArgs{
// ByteLength: pulumi.Int(4),
// })
// if err != nil {
// return err
// }
// _, err = sql.NewDatabaseInstance(ctx, "instance", &sql.DatabaseInstanceArgs{
// Region: pulumi.String("us-central1"),
// Settings: &sql.DatabaseInstanceSettingsArgs{
// Tier: pulumi.String("db-f1-micro"),
// IpConfiguration: &sql.DatabaseInstanceSettingsIpConfigurationArgs{
// Ipv4Enabled: pulumi.Bool(false),
// PrivateNetwork: privateNetwork.ID(),
// },
// },
// }, pulumi.Provider(google_beta), pulumi.DependsOn([]pulumi.Resource{
// privateVpcConnection,
// }))
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Database instances can be imported using one of any of these accepted formats
//
// ```sh
// $ pulumi import gcp:sql/databaseInstance:DatabaseInstance master projects/{{project}}/instances/{{name}}
// ```
//
// ```sh
// $ pulumi import gcp:sql/databaseInstance:DatabaseInstance master {{project}}/{{name}}
// ```
//
// ```sh
// $ pulumi import gcp:sql/databaseInstance:DatabaseInstance master {{name}}
// ```
//
// config and set on the server. When importing, double-check that your config has all the fields set that you expect- just seeing no diff isn't sufficient to know that your config could reproduce the imported resource.
type DatabaseInstance struct {
pulumi.CustomResourceState
// Configuration for creating a new instance as a clone of another instance.
Clone DatabaseInstanceClonePtrOutput `pulumi:"clone"`
// The connection name of the instance to be used in
// connection strings. For example, when connecting with [Cloud SQL Proxy](https://cloud.google.com/sql/docs/mysql/connect-admin-proxy).
ConnectionName pulumi.StringOutput `pulumi:"connectionName"`
// The MySQL, PostgreSQL or
// SQL Server (beta) version to use. Supported values include `MYSQL_5_6`,
// `MYSQL_5_7`, `MYSQL_8_0`, `POSTGRES_9_6`,`POSTGRES_10`, `POSTGRES_11`,
// `POSTGRES_12`, `POSTGRES_13`, `SQLSERVER_2017_STANDARD`,
// `SQLSERVER_2017_ENTERPRISE`, `SQLSERVER_2017_EXPRESS`, `SQLSERVER_2017_WEB`.
// [Database Version Policies](https://cloud.google.com/sql/docs/db-versions)
// includes an up-to-date reference of supported versions.
DatabaseVersion pulumi.StringPtrOutput `pulumi:"databaseVersion"`
// Whether or not to allow he provider to destroy the instance. Unless this field is set to false
// in state, a `destroy` or `update` command that deletes the instance will fail.
DeletionProtection pulumi.BoolPtrOutput `pulumi:"deletionProtection"`
// The full path to the encryption key used for the CMEK disk encryption. Setting
// up disk encryption currently requires manual steps outside of this provider.
// The provided key must be in the same region as the SQL instance. In order
// to use this feature, a special kind of service account must be created and
// granted permission on this key. This step can currently only be done
// manually, please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#service-account).
// That service account needs the `Cloud KMS > Cloud KMS CryptoKey Encrypter/Decrypter` role on your
// key - please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#grantkey).
EncryptionKeyName pulumi.StringOutput `pulumi:"encryptionKeyName"`
// The first IPv4 address of any type assigned.
FirstIpAddress pulumi.StringOutput `pulumi:"firstIpAddress"`
IpAddresses DatabaseInstanceIpAddressArrayOutput `pulumi:"ipAddresses"`
// The name of the existing instance that will
// act as the master in the replication setup. Note, this requires the master to
// have `binaryLogEnabled` set, as well as existing backups.
MasterInstanceName pulumi.StringOutput `pulumi:"masterInstanceName"`
// A name for this whitelist entry.
Name pulumi.StringOutput `pulumi:"name"`
// The first private (`PRIVATE`) IPv4 address assigned.
PrivateIpAddress pulumi.StringOutput `pulumi:"privateIpAddress"`
// The full project ID of the source instance.`
Project pulumi.StringOutput `pulumi:"project"`
// The first public (`PRIMARY`) IPv4 address assigned.
PublicIpAddress pulumi.StringOutput `pulumi:"publicIpAddress"`
// The region the instance will sit in. Note, Cloud SQL is not
// available in all regions - choose from one of the options listed [here](https://cloud.google.com/sql/docs/mysql/instance-locations).
// A valid region must be provided to use this resource. If a region is not provided in the resource definition,
// the provider region will be used instead, but this will be an apply-time error for instances if the provider
// region is not supported with Cloud SQL. If you choose not to provide the `region` argument for this resource,
// make sure you understand this.
Region pulumi.StringOutput `pulumi:"region"`
// The configuration for replication. The
// configuration is detailed below. Valid only for MySQL instances.
ReplicaConfiguration DatabaseInstanceReplicaConfigurationOutput `pulumi:"replicaConfiguration"`
// The context needed to restore the database to a backup run. This field will
// <<<<<<< HEAD
// cause the provider to trigger the database to restore from the backup run indicated. The configuration is detailed below.
// **NOTE:** Restoring from a backup is an imperative action and not recommended via the provider. Adding or modifying this
// block during resource creation/update will trigger the restore action after the resource is created/updated.
RestoreBackupContext DatabaseInstanceRestoreBackupContextPtrOutput `pulumi:"restoreBackupContext"`
// Initial root password. Required for MS SQL Server, ignored by MySQL and PostgreSQL.
RootPassword pulumi.StringPtrOutput `pulumi:"rootPassword"`
// The URI of the created resource.
SelfLink pulumi.StringOutput `pulumi:"selfLink"`
ServerCaCerts DatabaseInstanceServerCaCertArrayOutput `pulumi:"serverCaCerts"`
// The service account email address assigned to the
// instance.
ServiceAccountEmailAddress pulumi.StringOutput `pulumi:"serviceAccountEmailAddress"`
// The settings to use for the database. The
// configuration is detailed below. Required if `clone` is not set.
Settings DatabaseInstanceSettingsOutput `pulumi:"settings"`
}
// NewDatabaseInstance registers a new resource with the given unique name, arguments, and options.
func NewDatabaseInstance(ctx *pulumi.Context,
name string, args *DatabaseInstanceArgs, opts ...pulumi.ResourceOption) (*DatabaseInstance, error) {
if args == nil {
args = &DatabaseInstanceArgs{}
}
var resource DatabaseInstance
err := ctx.RegisterResource("gcp:sql/databaseInstance:DatabaseInstance", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetDatabaseInstance gets an existing DatabaseInstance resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetDatabaseInstance(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *DatabaseInstanceState, opts ...pulumi.ResourceOption) (*DatabaseInstance, error) {
var resource DatabaseInstance
err := ctx.ReadResource("gcp:sql/databaseInstance:DatabaseInstance", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering DatabaseInstance resources.
type databaseInstanceState struct {
// Configuration for creating a new instance as a clone of another instance.
Clone *DatabaseInstanceClone `pulumi:"clone"`
// The connection name of the instance to be used in
// connection strings. For example, when connecting with [Cloud SQL Proxy](https://cloud.google.com/sql/docs/mysql/connect-admin-proxy).
ConnectionName *string `pulumi:"connectionName"`
// The MySQL, PostgreSQL or
// SQL Server (beta) version to use. Supported values include `MYSQL_5_6`,
// `MYSQL_5_7`, `MYSQL_8_0`, `POSTGRES_9_6`,`POSTGRES_10`, `POSTGRES_11`,
// `POSTGRES_12`, `POSTGRES_13`, `SQLSERVER_2017_STANDARD`,
// `SQLSERVER_2017_ENTERPRISE`, `SQLSERVER_2017_EXPRESS`, `SQLSERVER_2017_WEB`.
// [Database Version Policies](https://cloud.google.com/sql/docs/db-versions)
// includes an up-to-date reference of supported versions.
DatabaseVersion *string `pulumi:"databaseVersion"`
// Whether or not to allow he provider to destroy the instance. Unless this field is set to false
// in state, a `destroy` or `update` command that deletes the instance will fail.
DeletionProtection *bool `pulumi:"deletionProtection"`
// The full path to the encryption key used for the CMEK disk encryption. Setting
// up disk encryption currently requires manual steps outside of this provider.
// The provided key must be in the same region as the SQL instance. In order
// to use this feature, a special kind of service account must be created and
// granted permission on this key. This step can currently only be done
// manually, please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#service-account).
// That service account needs the `Cloud KMS > Cloud KMS CryptoKey Encrypter/Decrypter` role on your
// key - please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#grantkey).
EncryptionKeyName *string `pulumi:"encryptionKeyName"`
// The first IPv4 address of any type assigned.
FirstIpAddress *string `pulumi:"firstIpAddress"`
IpAddresses []DatabaseInstanceIpAddress `pulumi:"ipAddresses"`
// The name of the existing instance that will
// act as the master in the replication setup. Note, this requires the master to
// have `binaryLogEnabled` set, as well as existing backups.
MasterInstanceName *string `pulumi:"masterInstanceName"`
// A name for this whitelist entry.
Name *string `pulumi:"name"`
// The first private (`PRIVATE`) IPv4 address assigned.
PrivateIpAddress *string `pulumi:"privateIpAddress"`
// The full project ID of the source instance.`
Project *string `pulumi:"project"`
// The first public (`PRIMARY`) IPv4 address assigned.
PublicIpAddress *string `pulumi:"publicIpAddress"`
// The region the instance will sit in. Note, Cloud SQL is not
// available in all regions - choose from one of the options listed [here](https://cloud.google.com/sql/docs/mysql/instance-locations).
// A valid region must be provided to use this resource. If a region is not provided in the resource definition,
// the provider region will be used instead, but this will be an apply-time error for instances if the provider
// region is not supported with Cloud SQL. If you choose not to provide the `region` argument for this resource,
// make sure you understand this.
Region *string `pulumi:"region"`
// The configuration for replication. The
// configuration is detailed below. Valid only for MySQL instances.
ReplicaConfiguration *DatabaseInstanceReplicaConfiguration `pulumi:"replicaConfiguration"`
// The context needed to restore the database to a backup run. This field will
// <<<<<<< HEAD
// cause the provider to trigger the database to restore from the backup run indicated. The configuration is detailed below.
// **NOTE:** Restoring from a backup is an imperative action and not recommended via the provider. Adding or modifying this
// block during resource creation/update will trigger the restore action after the resource is created/updated.
RestoreBackupContext *DatabaseInstanceRestoreBackupContext `pulumi:"restoreBackupContext"`
// Initial root password. Required for MS SQL Server, ignored by MySQL and PostgreSQL.
RootPassword *string `pulumi:"rootPassword"`
// The URI of the created resource.
SelfLink *string `pulumi:"selfLink"`
ServerCaCerts []DatabaseInstanceServerCaCert `pulumi:"serverCaCerts"`
// The service account email address assigned to the
// instance.
ServiceAccountEmailAddress *string `pulumi:"serviceAccountEmailAddress"`
// The settings to use for the database. The
// configuration is detailed below. Required if `clone` is not set.
Settings *DatabaseInstanceSettings `pulumi:"settings"`
}
type DatabaseInstanceState struct {
// Configuration for creating a new instance as a clone of another instance.
Clone DatabaseInstanceClonePtrInput
// The connection name of the instance to be used in
// connection strings. For example, when connecting with [Cloud SQL Proxy](https://cloud.google.com/sql/docs/mysql/connect-admin-proxy).
ConnectionName pulumi.StringPtrInput
// The MySQL, PostgreSQL or
// SQL Server (beta) version to use. Supported values include `MYSQL_5_6`,
// `MYSQL_5_7`, `MYSQL_8_0`, `POSTGRES_9_6`,`POSTGRES_10`, `POSTGRES_11`,
// `POSTGRES_12`, `POSTGRES_13`, `SQLSERVER_2017_STANDARD`,
// `SQLSERVER_2017_ENTERPRISE`, `SQLSERVER_2017_EXPRESS`, `SQLSERVER_2017_WEB`.
// [Database Version Policies](https://cloud.google.com/sql/docs/db-versions)
// includes an up-to-date reference of supported versions.
DatabaseVersion pulumi.StringPtrInput
// Whether or not to allow he provider to destroy the instance. Unless this field is set to false
// in state, a `destroy` or `update` command that deletes the instance will fail.
DeletionProtection pulumi.BoolPtrInput
// The full path to the encryption key used for the CMEK disk encryption. Setting
// up disk encryption currently requires manual steps outside of this provider.
// The provided key must be in the same region as the SQL instance. In order
// to use this feature, a special kind of service account must be created and
// granted permission on this key. This step can currently only be done
// manually, please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#service-account).
// That service account needs the `Cloud KMS > Cloud KMS CryptoKey Encrypter/Decrypter` role on your
// key - please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#grantkey).
EncryptionKeyName pulumi.StringPtrInput
// The first IPv4 address of any type assigned.
FirstIpAddress pulumi.StringPtrInput
IpAddresses DatabaseInstanceIpAddressArrayInput
// The name of the existing instance that will
// act as the master in the replication setup. Note, this requires the master to
// have `binaryLogEnabled` set, as well as existing backups.
MasterInstanceName pulumi.StringPtrInput
// A name for this whitelist entry.
Name pulumi.StringPtrInput
// The first private (`PRIVATE`) IPv4 address assigned.
PrivateIpAddress pulumi.StringPtrInput
// The full project ID of the source instance.`
Project pulumi.StringPtrInput
// The first public (`PRIMARY`) IPv4 address assigned.
PublicIpAddress pulumi.StringPtrInput
// The region the instance will sit in. Note, Cloud SQL is not
// available in all regions - choose from one of the options listed [here](https://cloud.google.com/sql/docs/mysql/instance-locations).
// A valid region must be provided to use this resource. If a region is not provided in the resource definition,
// the provider region will be used instead, but this will be an apply-time error for instances if the provider
// region is not supported with Cloud SQL. If you choose not to provide the `region` argument for this resource,
// make sure you understand this.
Region pulumi.StringPtrInput
// The configuration for replication. The
// configuration is detailed below. Valid only for MySQL instances.
ReplicaConfiguration DatabaseInstanceReplicaConfigurationPtrInput
// The context needed to restore the database to a backup run. This field will
// <<<<<<< HEAD
// cause the provider to trigger the database to restore from the backup run indicated. The configuration is detailed below.
// **NOTE:** Restoring from a backup is an imperative action and not recommended via the provider. Adding or modifying this
// block during resource creation/update will trigger the restore action after the resource is created/updated.
RestoreBackupContext DatabaseInstanceRestoreBackupContextPtrInput
// Initial root password. Required for MS SQL Server, ignored by MySQL and PostgreSQL.
RootPassword pulumi.StringPtrInput
// The URI of the created resource.
SelfLink pulumi.StringPtrInput
ServerCaCerts DatabaseInstanceServerCaCertArrayInput
// The service account email address assigned to the
// instance.
ServiceAccountEmailAddress pulumi.StringPtrInput
// The settings to use for the database. The
// configuration is detailed below. Required if `clone` is not set.
Settings DatabaseInstanceSettingsPtrInput
}
func (DatabaseInstanceState) ElementType() reflect.Type {
return reflect.TypeOf((*databaseInstanceState)(nil)).Elem()
}
type databaseInstanceArgs struct {
// Configuration for creating a new instance as a clone of another instance.
Clone *DatabaseInstanceClone `pulumi:"clone"`
// The MySQL, PostgreSQL or
// SQL Server (beta) version to use. Supported values include `MYSQL_5_6`,
// `MYSQL_5_7`, `MYSQL_8_0`, `POSTGRES_9_6`,`POSTGRES_10`, `POSTGRES_11`,
// `POSTGRES_12`, `POSTGRES_13`, `SQLSERVER_2017_STANDARD`,
// `SQLSERVER_2017_ENTERPRISE`, `SQLSERVER_2017_EXPRESS`, `SQLSERVER_2017_WEB`.
// [Database Version Policies](https://cloud.google.com/sql/docs/db-versions)
// includes an up-to-date reference of supported versions.
DatabaseVersion *string `pulumi:"databaseVersion"`
// Whether or not to allow he provider to destroy the instance. Unless this field is set to false
// in state, a `destroy` or `update` command that deletes the instance will fail.
DeletionProtection *bool `pulumi:"deletionProtection"`
// The full path to the encryption key used for the CMEK disk encryption. Setting
// up disk encryption currently requires manual steps outside of this provider.
// The provided key must be in the same region as the SQL instance. In order
// to use this feature, a special kind of service account must be created and
// granted permission on this key. This step can currently only be done
// manually, please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#service-account).
// That service account needs the `Cloud KMS > Cloud KMS CryptoKey Encrypter/Decrypter` role on your
// key - please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#grantkey).
EncryptionKeyName *string `pulumi:"encryptionKeyName"`
// The name of the existing instance that will
// act as the master in the replication setup. Note, this requires the master to
// have `binaryLogEnabled` set, as well as existing backups.
MasterInstanceName *string `pulumi:"masterInstanceName"`
// A name for this whitelist entry.
Name *string `pulumi:"name"`
// The full project ID of the source instance.`
Project *string `pulumi:"project"`
// The region the instance will sit in. Note, Cloud SQL is not
// available in all regions - choose from one of the options listed [here](https://cloud.google.com/sql/docs/mysql/instance-locations).
// A valid region must be provided to use this resource. If a region is not provided in the resource definition,
// the provider region will be used instead, but this will be an apply-time error for instances if the provider
// region is not supported with Cloud SQL. If you choose not to provide the `region` argument for this resource,
// make sure you understand this.
Region *string `pulumi:"region"`
// The configuration for replication. The
// configuration is detailed below. Valid only for MySQL instances.
ReplicaConfiguration *DatabaseInstanceReplicaConfiguration `pulumi:"replicaConfiguration"`
// The context needed to restore the database to a backup run. This field will
// <<<<<<< HEAD
// cause the provider to trigger the database to restore from the backup run indicated. The configuration is detailed below.
// **NOTE:** Restoring from a backup is an imperative action and not recommended via the provider. Adding or modifying this
// block during resource creation/update will trigger the restore action after the resource is created/updated.
RestoreBackupContext *DatabaseInstanceRestoreBackupContext `pulumi:"restoreBackupContext"`
// Initial root password. Required for MS SQL Server, ignored by MySQL and PostgreSQL.
RootPassword *string `pulumi:"rootPassword"`
// The settings to use for the database. The
// configuration is detailed below. Required if `clone` is not set.
Settings *DatabaseInstanceSettings `pulumi:"settings"`
}
// The set of arguments for constructing a DatabaseInstance resource.
type DatabaseInstanceArgs struct {
// Configuration for creating a new instance as a clone of another instance.
Clone DatabaseInstanceClonePtrInput
// The MySQL, PostgreSQL or
// SQL Server (beta) version to use. Supported values include `MYSQL_5_6`,
// `MYSQL_5_7`, `MYSQL_8_0`, `POSTGRES_9_6`,`POSTGRES_10`, `POSTGRES_11`,
// `POSTGRES_12`, `POSTGRES_13`, `SQLSERVER_2017_STANDARD`,
// `SQLSERVER_2017_ENTERPRISE`, `SQLSERVER_2017_EXPRESS`, `SQLSERVER_2017_WEB`.
// [Database Version Policies](https://cloud.google.com/sql/docs/db-versions)
// includes an up-to-date reference of supported versions.
DatabaseVersion pulumi.StringPtrInput
// Whether or not to allow he provider to destroy the instance. Unless this field is set to false
// in state, a `destroy` or `update` command that deletes the instance will fail.
DeletionProtection pulumi.BoolPtrInput
// The full path to the encryption key used for the CMEK disk encryption. Setting
// up disk encryption currently requires manual steps outside of this provider.
// The provided key must be in the same region as the SQL instance. In order
// to use this feature, a special kind of service account must be created and
// granted permission on this key. This step can currently only be done
// manually, please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#service-account).
// That service account needs the `Cloud KMS > Cloud KMS CryptoKey Encrypter/Decrypter` role on your
// key - please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#grantkey).
EncryptionKeyName pulumi.StringPtrInput
// The name of the existing instance that will
// act as the master in the replication setup. Note, this requires the master to
// have `binaryLogEnabled` set, as well as existing backups.
MasterInstanceName pulumi.StringPtrInput
// A name for this whitelist entry.
Name pulumi.StringPtrInput
// The full project ID of the source instance.`
Project pulumi.StringPtrInput
// The region the instance will sit in. Note, Cloud SQL is not
// available in all regions - choose from one of the options listed [here](https://cloud.google.com/sql/docs/mysql/instance-locations).
// A valid region must be provided to use this resource. If a region is not provided in the resource definition,
// the provider region will be used instead, but this will be an apply-time error for instances if the provider
// region is not supported with Cloud SQL. If you choose not to provide the `region` argument for this resource,
// make sure you understand this.
Region pulumi.StringPtrInput
// The configuration for replication. The
// configuration is detailed below. Valid only for MySQL instances.
ReplicaConfiguration DatabaseInstanceReplicaConfigurationPtrInput
// The context needed to restore the database to a backup run. This field will
// <<<<<<< HEAD
// cause the provider to trigger the database to restore from the backup run indicated. The configuration is detailed below.
// **NOTE:** Restoring from a backup is an imperative action and not recommended via the provider. Adding or modifying this
// block during resource creation/update will trigger the restore action after the resource is created/updated.
RestoreBackupContext DatabaseInstanceRestoreBackupContextPtrInput
// Initial root password. Required for MS SQL Server, ignored by MySQL and PostgreSQL.
RootPassword pulumi.StringPtrInput
// The settings to use for the database. The
// configuration is detailed below. Required if `clone` is not set.
Settings DatabaseInstanceSettingsPtrInput
}
func (DatabaseInstanceArgs) ElementType() reflect.Type {
return reflect.TypeOf((*databaseInstanceArgs)(nil)).Elem()
}
type DatabaseInstanceInput interface {
pulumi.Input
ToDatabaseInstanceOutput() DatabaseInstanceOutput
ToDatabaseInstanceOutputWithContext(ctx context.Context) DatabaseInstanceOutput
}
func (*DatabaseInstance) ElementType() reflect.Type {
return reflect.TypeOf((*DatabaseInstance)(nil))
}
func (i *DatabaseInstance) ToDatabaseInstanceOutput() DatabaseInstanceOutput {
return i.ToDatabaseInstanceOutputWithContext(context.Background())
}
func (i *DatabaseInstance) ToDatabaseInstanceOutputWithContext(ctx context.Context) DatabaseInstanceOutput {
return pulumi.ToOutputWithContext(ctx, i).(DatabaseInstanceOutput)
}
func (i *DatabaseInstance) ToDatabaseInstancePtrOutput() DatabaseInstancePtrOutput {
return i.ToDatabaseInstancePtrOutputWithContext(context.Background())
}
func (i *DatabaseInstance) ToDatabaseInstancePtrOutputWithContext(ctx context.Context) DatabaseInstancePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(DatabaseInstancePtrOutput)
}
type DatabaseInstancePtrInput interface {
pulumi.Input
ToDatabaseInstancePtrOutput() DatabaseInstancePtrOutput
ToDatabaseInstancePtrOutputWithContext(ctx context.Context) DatabaseInstancePtrOutput
}
type databaseInstancePtrType DatabaseInstanceArgs
func (*databaseInstancePtrType) ElementType() reflect.Type {
return reflect.TypeOf((**DatabaseInstance)(nil))
}
func (i *databaseInstancePtrType) ToDatabaseInstancePtrOutput() DatabaseInstancePtrOutput {
return i.ToDatabaseInstancePtrOutputWithContext(context.Background())
}
func (i *databaseInstancePtrType) ToDatabaseInstancePtrOutputWithContext(ctx context.Context) DatabaseInstancePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(DatabaseInstancePtrOutput)
}
// DatabaseInstanceArrayInput is an input type that accepts DatabaseInstanceArray and DatabaseInstanceArrayOutput values.
// You can construct a concrete instance of `DatabaseInstanceArrayInput` via:
//
// DatabaseInstanceArray{ DatabaseInstanceArgs{...} }
type DatabaseInstanceArrayInput interface {
pulumi.Input
ToDatabaseInstanceArrayOutput() DatabaseInstanceArrayOutput
ToDatabaseInstanceArrayOutputWithContext(context.Context) DatabaseInstanceArrayOutput
}
type DatabaseInstanceArray []DatabaseInstanceInput
func (DatabaseInstanceArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*DatabaseInstance)(nil)).Elem()
}
func (i DatabaseInstanceArray) ToDatabaseInstanceArrayOutput() DatabaseInstanceArrayOutput {
return i.ToDatabaseInstanceArrayOutputWithContext(context.Background())
}
func (i DatabaseInstanceArray) ToDatabaseInstanceArrayOutputWithContext(ctx context.Context) DatabaseInstanceArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(DatabaseInstanceArrayOutput)
}
// DatabaseInstanceMapInput is an input type that accepts DatabaseInstanceMap and DatabaseInstanceMapOutput values.
// You can construct a concrete instance of `DatabaseInstanceMapInput` via:
//
// DatabaseInstanceMap{ "key": DatabaseInstanceArgs{...} }
type DatabaseInstanceMapInput interface {
pulumi.Input
ToDatabaseInstanceMapOutput() DatabaseInstanceMapOutput
ToDatabaseInstanceMapOutputWithContext(context.Context) DatabaseInstanceMapOutput
}
type DatabaseInstanceMap map[string]DatabaseInstanceInput
func (DatabaseInstanceMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*DatabaseInstance)(nil)).Elem()
}
func (i DatabaseInstanceMap) ToDatabaseInstanceMapOutput() DatabaseInstanceMapOutput {
return i.ToDatabaseInstanceMapOutputWithContext(context.Background())
}
func (i DatabaseInstanceMap) ToDatabaseInstanceMapOutputWithContext(ctx context.Context) DatabaseInstanceMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(DatabaseInstanceMapOutput)
}
type DatabaseInstanceOutput struct{ *pulumi.OutputState }
func (DatabaseInstanceOutput) ElementType() reflect.Type {
return reflect.TypeOf((*DatabaseInstance)(nil))
}
func (o DatabaseInstanceOutput) ToDatabaseInstanceOutput() DatabaseInstanceOutput {
return o
}
func (o DatabaseInstanceOutput) ToDatabaseInstanceOutputWithContext(ctx context.Context) DatabaseInstanceOutput {
return o
}
func (o DatabaseInstanceOutput) ToDatabaseInstancePtrOutput() DatabaseInstancePtrOutput {
return o.ToDatabaseInstancePtrOutputWithContext(context.Background())
}
func (o DatabaseInstanceOutput) ToDatabaseInstancePtrOutputWithContext(ctx context.Context) DatabaseInstancePtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v DatabaseInstance) *DatabaseInstance {
return &v
}).(DatabaseInstancePtrOutput)
}
type DatabaseInstancePtrOutput struct{ *pulumi.OutputState }
func (DatabaseInstancePtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**DatabaseInstance)(nil))
}
func (o DatabaseInstancePtrOutput) ToDatabaseInstancePtrOutput() DatabaseInstancePtrOutput {
return o
}
func (o DatabaseInstancePtrOutput) ToDatabaseInstancePtrOutputWithContext(ctx context.Context) DatabaseInstancePtrOutput {
return o
}
func (o DatabaseInstancePtrOutput) Elem() DatabaseInstanceOutput {
return o.ApplyT(func(v *DatabaseInstance) DatabaseInstance {
if v != nil {
return *v
}
var ret DatabaseInstance
return ret
}).(DatabaseInstanceOutput)
}
type DatabaseInstanceArrayOutput struct{ *pulumi.OutputState }
func (DatabaseInstanceArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]DatabaseInstance)(nil))
}
func (o DatabaseInstanceArrayOutput) ToDatabaseInstanceArrayOutput() DatabaseInstanceArrayOutput {
return o
}
func (o DatabaseInstanceArrayOutput) ToDatabaseInstanceArrayOutputWithContext(ctx context.Context) DatabaseInstanceArrayOutput {
return o
}
func (o DatabaseInstanceArrayOutput) Index(i pulumi.IntInput) DatabaseInstanceOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) DatabaseInstance {
return vs[0].([]DatabaseInstance)[vs[1].(int)]
}).(DatabaseInstanceOutput)
}
type DatabaseInstanceMapOutput struct{ *pulumi.OutputState }
func (DatabaseInstanceMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]DatabaseInstance)(nil))
}
func (o DatabaseInstanceMapOutput) ToDatabaseInstanceMapOutput() DatabaseInstanceMapOutput {
return o
}
func (o DatabaseInstanceMapOutput) ToDatabaseInstanceMapOutputWithContext(ctx context.Context) DatabaseInstanceMapOutput {
return o
}
func (o DatabaseInstanceMapOutput) MapIndex(k pulumi.StringInput) DatabaseInstanceOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) DatabaseInstance {
return vs[0].(map[string]DatabaseInstance)[vs[1].(string)]
}).(DatabaseInstanceOutput)
}
func init() {
pulumi.RegisterOutputType(DatabaseInstanceOutput{})
pulumi.RegisterOutputType(DatabaseInstancePtrOutput{})
pulumi.RegisterOutputType(DatabaseInstanceArrayOutput{})
pulumi.RegisterOutputType(DatabaseInstanceMapOutput{})
}