Skip to content

Commit daa14bf

Browse files
connectorEnforcement field added along with modified test (#6667) (#13059)
Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent c522bcf commit daa14bf

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

.changelog/6667.txt

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

google/resource_sql_database_instance.go

+9
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,13 @@ is set to true. Defaults to ZONAL.`,
521521
},
522522
},
523523
},
524+
"connector_enforcement": {
525+
Type: schema.TypeString,
526+
Optional: true,
527+
Computed: true,
528+
ValidateFunc: validation.StringInSlice([]string{"NOT_REQUIRED", "REQUIRED"}, false),
529+
Description: `Specifies if connections must use Cloud SQL connectors.`,
530+
},
524531
},
525532
},
526533
Description: `The settings to use for the database. The configuration is detailed below.`,
@@ -1062,6 +1069,7 @@ func expandSqlDatabaseInstanceSettings(configured []interface{}) *sqladmin.Setti
10621069
SqlServerAuditConfig: expandSqlServerAuditConfig(_settings["sql_server_audit_config"].([]interface{})),
10631070
TimeZone: _settings["time_zone"].(string),
10641071
AvailabilityType: _settings["availability_type"].(string),
1072+
ConnectorEnforcement: _settings["connector_enforcement"].(string),
10651073
Collation: _settings["collation"].(string),
10661074
DataDiskSizeGb: int64(_settings["disk_size"].(int)),
10671075
DataDiskType: _settings["disk_type"].(string),
@@ -1576,6 +1584,7 @@ func flattenSettings(settings *sqladmin.Settings) []map[string]interface{} {
15761584
"activation_policy": settings.ActivationPolicy,
15771585
"availability_type": settings.AvailabilityType,
15781586
"collation": settings.Collation,
1587+
"connector_enforcement": settings.ConnectorEnforcement,
15791588
"disk_type": settings.DataDiskType,
15801589
"disk_size": settings.DataDiskSizeGb,
15811590
"pricing_plan": settings.PricingPlan,

google/resource_sql_database_instance_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ func TestAccSqlDatabaseInstance_withPrivateNetwork_withoutAllocatedIpRange(t *te
798798
}
799799

800800
func TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange(t *testing.T) {
801+
// Service Networking
802+
skipIfVcr(t)
801803
t.Parallel()
802804

803805
databaseName := "tf-test-" + randString(t, 10)
@@ -1233,6 +1235,8 @@ func TestAccSqlDatabaseInstance_ActiveDirectory(t *testing.T) {
12331235
}
12341236

12351237
func TestAccSqlDatabaseInstance_SqlServerAuditConfig(t *testing.T) {
1238+
// Service Networking
1239+
skipIfVcr(t)
12361240
t.Parallel()
12371241
databaseName := "tf-test-" + randString(t, 10)
12381242
rootPassword := randString(t, 15)
@@ -1887,6 +1891,7 @@ resource "google_sql_database_instance" "instance" {
18871891
}
18881892
18891893
activation_policy = "ALWAYS"
1894+
connector_enforcement = "REQUIRED"
18901895
}
18911896
}
18921897
`

website/docs/r/sql_database_instance.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ The `settings` block supports:
238238

239239
* `collation` - (Optional) The name of server instance collation.
240240

241+
* `connector_enforcement` - (Optional) Specifies if connections must use Cloud SQL connectors.
242+
241243
* `disk_autoresize` - (Optional) Enables auto-resizing of the storage size. Defaults to `true`.
242244

243245
* `disk_autoresize_limit` - (Optional) The maximum size to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit.

0 commit comments

Comments
 (0)