Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connectorEnforcement field added along with modified test #13059

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/6667.txt
@@ -0,0 +1,3 @@
```release-note:enhancement
cloudsql: added `connector_enforcement` field to `google_sql_database_instance` resource
```
9 changes: 9 additions & 0 deletions google/resource_sql_database_instance.go
Expand Up @@ -521,6 +521,13 @@ is set to true. Defaults to ZONAL.`,
},
},
},
"connector_enforcement": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"NOT_REQUIRED", "REQUIRED"}, false),
Description: `Specifies if connections must use Cloud SQL connectors.`,
},
},
},
Description: `The settings to use for the database. The configuration is detailed below.`,
Expand Down Expand Up @@ -1062,6 +1069,7 @@ func expandSqlDatabaseInstanceSettings(configured []interface{}) *sqladmin.Setti
SqlServerAuditConfig: expandSqlServerAuditConfig(_settings["sql_server_audit_config"].([]interface{})),
TimeZone: _settings["time_zone"].(string),
AvailabilityType: _settings["availability_type"].(string),
ConnectorEnforcement: _settings["connector_enforcement"].(string),
Collation: _settings["collation"].(string),
DataDiskSizeGb: int64(_settings["disk_size"].(int)),
DataDiskType: _settings["disk_type"].(string),
Expand Down Expand Up @@ -1576,6 +1584,7 @@ func flattenSettings(settings *sqladmin.Settings) []map[string]interface{} {
"activation_policy": settings.ActivationPolicy,
"availability_type": settings.AvailabilityType,
"collation": settings.Collation,
"connector_enforcement": settings.ConnectorEnforcement,
"disk_type": settings.DataDiskType,
"disk_size": settings.DataDiskSizeGb,
"pricing_plan": settings.PricingPlan,
Expand Down
5 changes: 5 additions & 0 deletions google/resource_sql_database_instance_test.go
Expand Up @@ -798,6 +798,8 @@ func TestAccSqlDatabaseInstance_withPrivateNetwork_withoutAllocatedIpRange(t *te
}

func TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange(t *testing.T) {
// Service Networking
skipIfVcr(t)
t.Parallel()

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

func TestAccSqlDatabaseInstance_SqlServerAuditConfig(t *testing.T) {
// Service Networking
skipIfVcr(t)
t.Parallel()
databaseName := "tf-test-" + randString(t, 10)
rootPassword := randString(t, 15)
Expand Down Expand Up @@ -1887,6 +1891,7 @@ resource "google_sql_database_instance" "instance" {
}

activation_policy = "ALWAYS"
connector_enforcement = "REQUIRED"
}
}
`
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/sql_database_instance.html.markdown
Expand Up @@ -238,6 +238,8 @@ The `settings` block supports:

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

* `connector_enforcement` - (Optional) Specifies if connections must use Cloud SQL connectors.

* `disk_autoresize` - (Optional) Enables auto-resizing of the storage size. Defaults to `true`.

* `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.
Expand Down