Skip to content

Commit 4038938

Browse files
feng-zheniharika-98
authored andcommitted
feat: support a new field server_ca_pool of Cloud SQL instances (GoogleCloudPlatform#12623)
1 parent 255a81c commit 4038938

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl

+15-6
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ var (
8181
"settings.0.ip_configuration.0.psc_config",
8282
"settings.0.ip_configuration.0.ssl_mode",
8383
"settings.0.ip_configuration.0.server_ca_mode",
84+
"settings.0.ip_configuration.0.server_ca_pool",
8485
}
8586

8687
maintenanceWindowKeys = []string{
@@ -519,12 +520,18 @@ is set to true. Defaults to ZONAL.`,
519520
Description: `Specify how SSL connection should be enforced in DB connections.`,
520521
AtLeastOneOf: ipConfigurationKeys,
521522
},
522-
"server_ca_mode": {
523-
Type: schema.TypeString,
524-
Optional: true,
525-
Computed: true,
526-
ValidateFunc: validation.StringInSlice([]string{"CA_MODE_UNSPECIFIED", "GOOGLE_MANAGED_INTERNAL_CA", "GOOGLE_MANAGED_CAS_CA"}, false),
527-
Description: `Specify how the server certificate's Certificate Authority is hosted.`,
523+
"server_ca_mode": {
524+
Type: schema.TypeString,
525+
Optional: true,
526+
Computed: true,
527+
ValidateFunc: validation.StringInSlice([]string{"CA_MODE_UNSPECIFIED", "GOOGLE_MANAGED_INTERNAL_CA", "GOOGLE_MANAGED_CAS_CA", "CUSTOMER_MANAGED_CAS_CA"}, false),
528+
Description: `Specify how the server certificate's Certificate Authority is hosted.`,
529+
AtLeastOneOf: ipConfigurationKeys,
530+
},
531+
"server_ca_pool": {
532+
Type: schema.TypeString,
533+
Optional: true,
534+
Description: `The resource name of the server CA pool for an instance with "CUSTOMER_MANAGED_CAS_CA" as the "server_ca_mode".`,
528535
AtLeastOneOf: ipConfigurationKeys,
529536
},
530537
},
@@ -1453,6 +1460,7 @@ func expandIpConfiguration(configured []interface{}, databaseVersion string) *sq
14531460
PscConfig: expandPscConfig(_ipConfiguration["psc_config"].(*schema.Set).List()),
14541461
SslMode: _ipConfiguration["ssl_mode"].(string),
14551462
ServerCaMode: _ipConfiguration["server_ca_mode"].(string),
1463+
ServerCaPool: _ipConfiguration["server_ca_pool"].(string),
14561464
}
14571465
}
14581466

@@ -2377,6 +2385,7 @@ func flattenIpConfiguration(ipConfiguration *sqladmin.IpConfiguration, d *schema
23772385
"enable_private_path_for_google_cloud_services": ipConfiguration.EnablePrivatePathForGoogleCloudServices,
23782386
"ssl_mode": ipConfiguration.SslMode,
23792387
"server_ca_mode": ipConfiguration.ServerCaMode,
2388+
"server_ca_pool": ipConfiguration.ServerCaPool,
23802389
}
23812390

23822391
if ipConfiguration.AuthorizedNetworks != nil {

mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,10 @@ func TestAccSqlDatabaseInstance_useInternalCaByDefault(t *testing.T) {
26632663
Steps: []resource.TestStep{
26642664
{
26652665
Config: fmt.Sprintf(testGoogleSqlDatabaseInstance_basic3, databaseName),
2666-
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_INTERNAL_CA")),
2666+
Check: resource.ComposeTestCheckFunc(
2667+
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_INTERNAL_CA"),
2668+
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_pool", ""),
2669+
),
26672670
},
26682671
{
26692672
ResourceName: resourceName,
@@ -2689,7 +2692,10 @@ func TestAccSqlDatabaseInstance_useCasBasedServerCa(t *testing.T) {
26892692
Steps: []resource.TestStep{
26902693
{
26912694
Config: testGoogleSqlDatabaseInstance_setCasServerCa(databaseName, "GOOGLE_MANAGED_CAS_CA"),
2692-
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_CAS_CA")),
2695+
Check: resource.ComposeTestCheckFunc(
2696+
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_CAS_CA"),
2697+
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_pool", ""),
2698+
),
26932699
},
26942700
{
26952701
ResourceName: resourceName,

mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ This setting can be updated, but it cannot be removed after it is set.
411411

412412
* `server_ca_mode` - (Optional) Specify how the server certificate's Certificate Authority is hosted. Supported values are `GOOGLE_MANAGED_INTERNAL_CA` and `GOOGLE_MANAGED_CAS_CA`.
413413

414+
* `server_ca_pool` - (Optional) The resource name of the server CA pool for an instance with `CUSTOMER_MANAGED_CAS_CA` as the `server_ca_mode`.
415+
414416
* `allocated_ip_range` - (Optional) The name of the allocated ip range for the private ip CloudSQL instance. For example: "google-managed-services-default". If set, the instance ip will be created in the allocated range. The range name must comply with [RFC 1035](https://datatracker.ietf.org/doc/html/rfc1035). Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])?.
415417

416418
* `enable_private_path_for_google_cloud_services` - (Optional) Whether Google Cloud services such as BigQuery are allowed to access data in this Cloud SQL instance over a private IP connection. SQLSERVER database type is not supported.

0 commit comments

Comments
 (0)