Skip to content

Commit 6ab8512

Browse files
feat: support a new field server_ca_pool of Cloud SQL instances (#12623) (#9008)
[upstream:023e0c52cdd2e2a1aeef8bff6dfaefe4eb3afd34] Signed-off-by: Modular Magician <[email protected]>
1 parent 99acc0e commit 6ab8512

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

Diff for: .changelog/12623.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
sql: added `server_ca_pool` field to `google_sql_database_instance` resource.
3+
```

Diff for: google-beta/services/sql/resource_sql_database_instance.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ var (
8383
"settings.0.ip_configuration.0.psc_config",
8484
"settings.0.ip_configuration.0.ssl_mode",
8585
"settings.0.ip_configuration.0.server_ca_mode",
86+
"settings.0.ip_configuration.0.server_ca_pool",
8687
}
8788

8889
maintenanceWindowKeys = []string{
@@ -525,10 +526,16 @@ is set to true. Defaults to ZONAL.`,
525526
Type: schema.TypeString,
526527
Optional: true,
527528
Computed: true,
528-
ValidateFunc: validation.StringInSlice([]string{"CA_MODE_UNSPECIFIED", "GOOGLE_MANAGED_INTERNAL_CA", "GOOGLE_MANAGED_CAS_CA"}, false),
529+
ValidateFunc: validation.StringInSlice([]string{"CA_MODE_UNSPECIFIED", "GOOGLE_MANAGED_INTERNAL_CA", "GOOGLE_MANAGED_CAS_CA", "CUSTOMER_MANAGED_CAS_CA"}, false),
529530
Description: `Specify how the server certificate's Certificate Authority is hosted.`,
530531
AtLeastOneOf: ipConfigurationKeys,
531532
},
533+
"server_ca_pool": {
534+
Type: schema.TypeString,
535+
Optional: true,
536+
Description: `The resource name of the server CA pool for an instance with "CUSTOMER_MANAGED_CAS_CA" as the "server_ca_mode".`,
537+
AtLeastOneOf: ipConfigurationKeys,
538+
},
532539
},
533540
},
534541
},
@@ -1455,6 +1462,7 @@ func expandIpConfiguration(configured []interface{}, databaseVersion string) *sq
14551462
PscConfig: expandPscConfig(_ipConfiguration["psc_config"].(*schema.Set).List()),
14561463
SslMode: _ipConfiguration["ssl_mode"].(string),
14571464
ServerCaMode: _ipConfiguration["server_ca_mode"].(string),
1465+
ServerCaPool: _ipConfiguration["server_ca_pool"].(string),
14581466
}
14591467
}
14601468

@@ -2379,6 +2387,7 @@ func flattenIpConfiguration(ipConfiguration *sqladmin.IpConfiguration, d *schema
23792387
"enable_private_path_for_google_cloud_services": ipConfiguration.EnablePrivatePathForGoogleCloudServices,
23802388
"ssl_mode": ipConfiguration.SslMode,
23812389
"server_ca_mode": ipConfiguration.ServerCaMode,
2390+
"server_ca_pool": ipConfiguration.ServerCaPool,
23822391
}
23832392

23842393
if ipConfiguration.AuthorizedNetworks != nil {

Diff for: google-beta/services/sql/resource_sql_database_instance_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -2665,7 +2665,10 @@ func TestAccSqlDatabaseInstance_useInternalCaByDefault(t *testing.T) {
26652665
Steps: []resource.TestStep{
26662666
{
26672667
Config: fmt.Sprintf(testGoogleSqlDatabaseInstance_basic3, databaseName),
2668-
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_INTERNAL_CA")),
2668+
Check: resource.ComposeTestCheckFunc(
2669+
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_INTERNAL_CA"),
2670+
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_pool", ""),
2671+
),
26692672
},
26702673
{
26712674
ResourceName: resourceName,
@@ -2691,7 +2694,10 @@ func TestAccSqlDatabaseInstance_useCasBasedServerCa(t *testing.T) {
26912694
Steps: []resource.TestStep{
26922695
{
26932696
Config: testGoogleSqlDatabaseInstance_setCasServerCa(databaseName, "GOOGLE_MANAGED_CAS_CA"),
2694-
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_CAS_CA")),
2697+
Check: resource.ComposeTestCheckFunc(
2698+
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_CAS_CA"),
2699+
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_pool", ""),
2700+
),
26952701
},
26962702
{
26972703
ResourceName: resourceName,

Diff for: 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)