Skip to content

Commit edd5e59

Browse files
Deprecate google_sql_database_instance.settings.ip_configuration's require_ssl in favor of ssl_mode (#11154) (#7804)
[upstream:bc7cde468a0c1c8ec3addac9b63479f743c218b9] Signed-off-by: Modular Magician <[email protected]>
1 parent 70c9ce2 commit edd5e59

File tree

4 files changed

+16
-35
lines changed

4 files changed

+16
-35
lines changed

Diff for: .changelog/11154.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:deprecation
2+
sql: `settings.ip_configuration.require_ssl` is now deprecated within `google_sql_database_instance`. Please use `settings.ip_configuration.ssl_mode` instead.
3+
```

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

+5-17
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ var (
7676
ipConfigurationKeys = []string{
7777
"settings.0.ip_configuration.0.authorized_networks",
7878
"settings.0.ip_configuration.0.ipv4_enabled",
79-
"settings.0.ip_configuration.0.require_ssl",
8079
"settings.0.ip_configuration.0.private_network",
8180
"settings.0.ip_configuration.0.allocated_ip_range",
8281
"settings.0.ip_configuration.0.enable_private_path_for_google_cloud_services",
@@ -438,13 +437,6 @@ is set to true. Defaults to ZONAL.`,
438437
AtLeastOneOf: ipConfigurationKeys,
439438
Description: `Whether this Cloud SQL instance should be assigned a public IPV4 address. At least ipv4_enabled must be enabled or a private_network must be configured.`,
440439
},
441-
"require_ssl": {
442-
Type: schema.TypeBool,
443-
Optional: true,
444-
AtLeastOneOf: ipConfigurationKeys,
445-
Description: `Whether SSL connections over IP are enforced or not. To change this field, also set the corresponding value in ssl_mode if it has been set too.`,
446-
Deprecated: "`require_ssl` will be fully deprecated in a future major release. For now, please use `ssl_mode` with a compatible `require_ssl` value instead.",
447-
},
448440
"private_network": {
449441
Type: schema.TypeString,
450442
Optional: true,
@@ -493,7 +485,7 @@ is set to true. Defaults to ZONAL.`,
493485
Optional: true,
494486
Computed: true,
495487
ValidateFunc: validation.StringInSlice([]string{"ALLOW_UNENCRYPTED_AND_ENCRYPTED", "ENCRYPTED_ONLY", "TRUSTED_CLIENT_CERTIFICATE_REQUIRED"}, false),
496-
Description: `Specify how SSL connection should be enforced in DB connections. This field provides more SSL enforcment options compared to require_ssl. To change this field, also set the correspoding value in require_ssl until next major release.`,
488+
Description: `Specify how SSL connection should be enforced in DB connections.`,
497489
AtLeastOneOf: ipConfigurationKeys,
498490
},
499491
},
@@ -1386,20 +1378,21 @@ func expandIpConfiguration(configured []interface{}, databaseVersion string) *sq
13861378

13871379
_ipConfiguration := configured[0].(map[string]interface{})
13881380

1389-
forceSendFields := []string{"Ipv4Enabled", "RequireSsl"}
1381+
forceSendFields := []string{"Ipv4Enabled"}
1382+
nullFields := []string{"RequireSsl"}
13901383

13911384
if !strings.HasPrefix(databaseVersion, "SQLSERVER") {
13921385
forceSendFields = append(forceSendFields, "EnablePrivatePathForGoogleCloudServices")
13931386
}
13941387

13951388
return &sqladmin.IpConfiguration{
13961389
Ipv4Enabled: _ipConfiguration["ipv4_enabled"].(bool),
1397-
RequireSsl: _ipConfiguration["require_ssl"].(bool),
13981390
PrivateNetwork: _ipConfiguration["private_network"].(string),
13991391
AllocatedIpRange: _ipConfiguration["allocated_ip_range"].(string),
14001392
AuthorizedNetworks: expandAuthorizedNetworks(_ipConfiguration["authorized_networks"].(*schema.Set).List()),
14011393
EnablePrivatePathForGoogleCloudServices: _ipConfiguration["enable_private_path_for_google_cloud_services"].(bool),
14021394
ForceSendFields: forceSendFields,
1395+
NullFields: nullFields,
14031396
PscConfig: expandPscConfig(_ipConfiguration["psc_config"].(*schema.Set).List()),
14041397
SslMode: _ipConfiguration["ssl_mode"].(string),
14051398
}
@@ -2240,8 +2233,8 @@ func flattenIpConfiguration(ipConfiguration *sqladmin.IpConfiguration, d *schema
22402233
"ipv4_enabled": ipConfiguration.Ipv4Enabled,
22412234
"private_network": ipConfiguration.PrivateNetwork,
22422235
"allocated_ip_range": ipConfiguration.AllocatedIpRange,
2243-
"require_ssl": ipConfiguration.RequireSsl,
22442236
"enable_private_path_for_google_cloud_services": ipConfiguration.EnablePrivatePathForGoogleCloudServices,
2237+
"ssl_mode": ipConfiguration.SslMode,
22452238
}
22462239

22472240
if ipConfiguration.AuthorizedNetworks != nil {
@@ -2252,11 +2245,6 @@ func flattenIpConfiguration(ipConfiguration *sqladmin.IpConfiguration, d *schema
22522245
data["psc_config"] = flattenPscConfigs(ipConfiguration.PscConfig)
22532246
}
22542247

2255-
// We store the ssl_mode value only if the customer already uses `ssl_mode`.
2256-
if _, ok := d.GetOk("settings.0.ip_configuration.0.ssl_mode"); ok {
2257-
data["ssl_mode"] = ipConfiguration.SslMode
2258-
}
2259-
22602248
return []map[string]interface{}{data}
22612249
}
22622250

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

+7-12
Original file line numberDiff line numberDiff line change
@@ -2346,9 +2346,8 @@ func TestAccSqlDatabaseInstance_updateSslOptionsForPostgreSQL(t *testing.T) {
23462346
// We don't do ImportStateVerify for the ssl_mode because of the implementation. The ssl_mode is expected to be discarded if the local state doesn't have it.
23472347
Steps: []resource.TestStep{
23482348
{
2349-
Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, false, "ALLOW_UNENCRYPTED_AND_ENCRYPTED"),
2349+
Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, "ALLOW_UNENCRYPTED_AND_ENCRYPTED"),
23502350
Check: resource.ComposeTestCheckFunc(
2351-
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.require_ssl", "false"),
23522351
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.ssl_mode", "ALLOW_UNENCRYPTED_AND_ENCRYPTED"),
23532352
),
23542353
},
@@ -2359,9 +2358,8 @@ func TestAccSqlDatabaseInstance_updateSslOptionsForPostgreSQL(t *testing.T) {
23592358
ImportStateVerifyIgnore: []string{"deletion_protection", "settings.0.ip_configuration.0.ssl_mode"},
23602359
},
23612360
{
2362-
Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, false, "ENCRYPTED_ONLY"),
2361+
Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, "ENCRYPTED_ONLY"),
23632362
Check: resource.ComposeTestCheckFunc(
2364-
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.require_ssl", "false"),
23652363
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.ssl_mode", "ENCRYPTED_ONLY"),
23662364
),
23672365
},
@@ -2372,9 +2370,8 @@ func TestAccSqlDatabaseInstance_updateSslOptionsForPostgreSQL(t *testing.T) {
23722370
ImportStateVerifyIgnore: []string{"deletion_protection", "settings.0.ip_configuration.0.ssl_mode"},
23732371
},
23742372
{
2375-
Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, true, "TRUSTED_CLIENT_CERTIFICATE_REQUIRED"),
2373+
Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, "TRUSTED_CLIENT_CERTIFICATE_REQUIRED"),
23762374
Check: resource.ComposeTestCheckFunc(
2377-
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.require_ssl", "true"),
23782375
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.ssl_mode", "TRUSTED_CLIENT_CERTIFICATE_REQUIRED"),
23792376
),
23802377
},
@@ -2385,9 +2382,8 @@ func TestAccSqlDatabaseInstance_updateSslOptionsForPostgreSQL(t *testing.T) {
23852382
ImportStateVerifyIgnore: []string{"deletion_protection", "settings.0.ip_configuration.0.ssl_mode"},
23862383
},
23872384
{
2388-
Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, false, "ALLOW_UNENCRYPTED_AND_ENCRYPTED"),
2385+
Config: testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName, databaseVersion, "ALLOW_UNENCRYPTED_AND_ENCRYPTED"),
23892386
Check: resource.ComposeTestCheckFunc(
2390-
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.require_ssl", "false"),
23912387
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.ssl_mode", "ALLOW_UNENCRYPTED_AND_ENCRYPTED"),
23922388
),
23932389
},
@@ -2401,7 +2397,7 @@ func TestAccSqlDatabaseInstance_updateSslOptionsForPostgreSQL(t *testing.T) {
24012397
})
24022398
}
24032399

2404-
func testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName string, databaseVersion string, requireSsl bool, sslMode string) string {
2400+
func testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName string, databaseVersion string, sslMode string) string {
24052401
return fmt.Sprintf(`
24062402
resource "google_sql_database_instance" "instance" {
24072403
name = "%s"
@@ -2412,11 +2408,10 @@ resource "google_sql_database_instance" "instance" {
24122408
tier = "db-g1-small"
24132409
ip_configuration {
24142410
ipv4_enabled = true
2415-
require_ssl = %t
24162411
ssl_mode = "%s"
24172412
}
24182413
}
2419-
}`, databaseName, databaseVersion, requireSsl, sslMode)
2414+
}`, databaseName, databaseVersion, sslMode)
24202415
}
24212416

24222417
func testAccSqlDatabaseInstance_sqlMysqlInstancePvpExample(context map[string]interface{}) string {
@@ -2500,7 +2495,7 @@ resource "google_sql_database_instance" "instance" {
25002495
collation = "Polish_CI_AS"
25012496
ip_configuration {
25022497
ipv4_enabled = true
2503-
require_ssl = true
2498+
ssl_mode = "ENCRYPTED_ONLY"
25042499
}
25052500
}
25062501
}

Diff for: website/docs/r/sql_database_instance.html.markdown

+1-6
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,7 @@ Specifying a network enables private IP.
375375
At least `ipv4_enabled` must be enabled or a `private_network` must be configured.
376376
This setting can be updated, but it cannot be removed after it is set.
377377

378-
* `require_ssl` - (Optional, Deprecated) Whether SSL connections over IP are enforced or not. To change this field, also set the corresponding value in `ssl_mode`. It will be fully deprecated in a future major release. For now, please use `ssl_mode` with a compatible `require_ssl` value instead.
379-
380-
* `ssl_mode` - (Optional) Specify how SSL connection should be enforced in DB connections. This field provides more SSL enforcment options compared to `require_ssl`. To change this field, also set the correspoding value in `require_ssl`.
381-
* For PostgreSQL instances, the value pairs are listed in the [API reference doc](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances#ipconfiguration) for `ssl_mode` field.
382-
* For MySQL instances, use the same value pairs as the PostgreSQL instances.
383-
* For SQL Server instances, set it to `ALLOW_UNENCRYPTED_AND_ENCRYPTED` when `require_ssl=false` and `ENCRYPTED_ONLY` otherwise.
378+
* `ssl_mode` - (Optional) Specify how SSL connection should be enforced in DB connections.
384379

385380
* `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])?.
386381

0 commit comments

Comments
 (0)