diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl index 265e7b2c1c07..2e1ceb6241f1 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl @@ -597,6 +597,13 @@ API (for read pools, effective_availability_type may differ from availability_ty Computed: true, Description: `Provisioned throughput measured in MiB per second for the data disk. This field is only used for HYPERDISK_BALANCED disk types.`, }, + "replication_lag_max_seconds": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.IntAtLeast(0), + Description: `The number of seconds between two consecutive instance recreations after which replication is considered stuck and the replica is recreated. 0 disables the check.`, + }, "connection_pool_config": { Type: schema.TypeSet, Optional: true, @@ -2024,6 +2031,7 @@ func expandSqlDatabaseInstanceSettings(configured []interface{}, databaseVersion DataDiskType: _settings["disk_type"].(string), DataDiskProvisionedIops: int64(_settings["data_disk_provisioned_iops"].(int)), DataDiskProvisionedThroughput: int64(_settings["data_disk_provisioned_throughput"].(int)), + ReplicationLagMaxSeconds: int64(_settings["replication_lag_max_seconds"].(int)), PricingPlan: _settings["pricing_plan"].(string), DeletionProtectionEnabled: _settings["deletion_protection_enabled"].(bool), EnableGoogleMlIntegration: _settings["enable_google_ml_integration"].(bool), @@ -3288,6 +3296,7 @@ func flattenSettings(settings *sqladmin.Settings, iType string, d *schema.Resour "disk_size": settings.DataDiskSizeGb, "data_disk_provisioned_iops": settings.DataDiskProvisionedIops, "data_disk_provisioned_throughput": settings.DataDiskProvisionedThroughput, + "replication_lag_max_seconds": settings.ReplicationLagMaxSeconds, "pricing_plan": settings.PricingPlan, "user_labels": settings.UserLabels, "password_validation_policy": settings.PasswordValidationPolicy, diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml.tmpl b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml.tmpl index 869fed364817..bd951bfe1d15 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml.tmpl +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml.tmpl @@ -142,6 +142,7 @@ fields: - api_field: 'settings.dataDiskProvisionedThroughput' - api_field: 'settings.dataDiskType' field: 'settings.disk_type' + - api_field: 'settings.replicationLagMaxSeconds' - api_field: 'settings.edition' - api_field: 'settings.enableDataplexIntegration' - api_field: 'settings.enableGoogleMlIntegration' diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl index c2aef5be599d..6812f6e7556f 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl @@ -610,6 +610,33 @@ func TestAccSqlDatabaseInstance_settings_basic(t *testing.T) { }) } +func TestAccSqlDatabaseInstance_replicationLagMaxSeconds(t *testing.T) { + t.Parallel() + + databaseName := "tf-test-" + acctest.RandString(t, 10) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccSqlDatabaseInstanceDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf( + testGoogleSqlDatabaseInstance_replicationLagMaxSeconds, databaseName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_sql_database_instance.instance", "settings.0.replication_lag_max_seconds", "600"), + ), + }, + { + ResourceName: "google_sql_database_instance.instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"deletion_protection"}, + }, + }, + }) +} + func TestAccSqlDatabaseInstance_settings_secondary(t *testing.T) { t.Parallel() @@ -8351,6 +8378,19 @@ resource "google_sql_database_instance" "instance" { } ` +var testGoogleSqlDatabaseInstance_replicationLagMaxSeconds = ` +resource "google_sql_database_instance" "instance" { + name = "%s" + region = "us-central1" + database_version = "MYSQL_5_7" + deletion_protection = false + settings { + tier = "db-g1-small" + replication_lag_max_seconds = 600 + } +} +` + var testGoogleSqlDatabaseInstance_settings_secondary = ` resource "google_sql_database_instance" "instance" { name = "%s" diff --git a/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown b/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown index 30c688739323..64988ef2f619 100644 --- a/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown @@ -496,6 +496,8 @@ The `settings` block supports: * `data_disk_provisioned_throughput` - (Optional) Provisioned throughput measured in MiB per second for the data disk. This field is only used for `HYPERDISK_BALANCED` disk types. +* `replication_lag_max_seconds` - (Optional) The number of seconds between two consecutive instance recreations after which replication is considered stuck and the replica is recreated. `0` disables the check. + * `node_count` - For a read pool instance, the number of nodes in the read pool. For read pools with auto scaling enabled, this field is read only. * `pricing_plan` - (Optional) Pricing plan for this instance, can only be `PER_USE`.