diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.erb b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.erb index 939cba3fa0ad..eea792b5136a 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.erb +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.erb @@ -397,6 +397,11 @@ is set to true. Defaults to ZONAL.`, Default: 0, Description: `The maximum size, in GB, to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit.`, }, + "enable_google_ml_integration": { + Type: schema.TypeBool, + Optional: true, + Description: `Enables Vertex AI Integration.`, + }, "disk_size": { Type: schema.TypeInt, Optional: true, @@ -1268,7 +1273,7 @@ func expandSqlDatabaseInstanceSettings(configured []interface{}, databaseVersion Tier: _settings["tier"].(string), Edition: _settings["edition"].(string), AdvancedMachineFeatures: expandSqlServerAdvancedMachineFeatures(_settings["advanced_machine_features"].([]interface{})), - ForceSendFields: []string{"StorageAutoResize"}, + ForceSendFields: []string{"StorageAutoResize", "EnableGoogleMlIntegration"}, ActivationPolicy: _settings["activation_policy"].(string), ActiveDirectoryConfig: expandActiveDirectoryConfig(_settings["active_directory_config"].([]interface{})), DenyMaintenancePeriods: expandDenyMaintenancePeriod(_settings["deny_maintenance_period"].([]interface{})), @@ -1281,6 +1286,7 @@ func expandSqlDatabaseInstanceSettings(configured []interface{}, databaseVersion DataDiskType: _settings["disk_type"].(string), PricingPlan: _settings["pricing_plan"].(string), DeletionProtectionEnabled: _settings["deletion_protection_enabled"].(bool), + EnableGoogleMlIntegration: _settings["enable_google_ml_integration"].(bool), UserLabels: tpgresource.ConvertStringMap(_settings["user_labels"].(map[string]interface{})), BackupConfiguration: expandBackupConfiguration(_settings["backup_configuration"].([]interface{})), DatabaseFlags: expandDatabaseFlags(_settings["database_flags"].(*schema.Set).List()), @@ -1933,6 +1939,11 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) instance.InstanceType = d.Get("instance_type").(string) } + // Database Version is required for enabling Google ML integration. + if d.HasChange("settings.0.enable_google_ml_integration") { + instance.DatabaseVersion = databaseVersion + } + err = transport_tpg.Retry(transport_tpg.RetryOptions{ RetryFunc: func() (rerr error) { op, rerr = config.NewSqlAdminClient(userAgent).Instances.Update(project, d.Get("name").(string), instance).Do() @@ -2100,6 +2111,8 @@ func flattenSettings(settings *sqladmin.Settings, d *schema.ResourceData) []map[ data["disk_autoresize"] = settings.StorageAutoResize data["disk_autoresize_limit"] = settings.StorageAutoResizeLimit + data["enable_google_ml_integration"] = settings.EnableGoogleMlIntegration + if settings.UserLabels != nil { data["user_labels"] = settings.UserLabels } diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go index 1ce3c2f3c092..a9ee4ecfd70d 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go @@ -1353,6 +1353,38 @@ func TestAccSqlDatabaseInstance_PointInTimeRecoveryEnabledForSqlServer(t *testin }) } +func TestAccSqlDatabaseInstance_EnableGoogleMlIntegration(t *testing.T) { + t.Parallel() + + masterID := acctest.RandInt(t) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccSqlDatabaseInstanceDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testGoogleSqlDatabaseInstance_EnableGoogleMlIntegration(masterID, true, "POSTGRES_14"), + }, + { + ResourceName: "google_sql_database_instance.instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"deletion_protection", "root_password"}, + }, + { + Config: testGoogleSqlDatabaseInstance_EnableGoogleMlIntegration(masterID, false, "POSTGRES_14"), + }, + { + ResourceName: "google_sql_database_instance.instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"deletion_protection", "root_password"}, + }, + }, + }) +} + func TestAccSqlDatabaseInstance_insights(t *testing.T) { t.Parallel() @@ -3857,6 +3889,22 @@ resource "google_sql_database_instance" "instance" { `, masterID, dbVersion, masterID, pointInTimeRecoveryEnabled) } +func testGoogleSqlDatabaseInstance_EnableGoogleMlIntegration(masterID int, enableGoogleMlIntegration bool, dbVersion string) string { + return fmt.Sprintf(` +resource "google_sql_database_instance" "instance" { + name = "tf-test-%d" + region = "us-central1" + database_version = "%s" + deletion_protection = false + root_password = "rand-pwd-%d" + settings { + tier = "db-custom-2-13312" + enable_google_ml_integration = %t + } +} +`, masterID, dbVersion, masterID, enableGoogleMlIntegration) +} + func testGoogleSqlDatabaseInstance_BackupRetention(masterID int) string { return fmt.Sprintf(` resource "google_sql_database_instance" "instance" { 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 fc057586edbc..3bdf7ad72772 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 @@ -288,6 +288,8 @@ The `settings` block supports: * `deletion_protection_enabled` - (Optional) Enables deletion protection of an instance at the GCP level. Enabling this protection will guard against accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform) by enabling the [GCP Cloud SQL instance deletion protection](https://cloud.google.com/sql/docs/postgres/deletion-protection). Terraform provider support was introduced in version 4.48.0. Defaults to `false`. +* `enable_google_ml_integration` - (Optional) Enables [Cloud SQL instances to connect to Vertex AI](https://cloud.google.com/sql/docs/postgres/integrate-cloud-sql-with-vertex-ai) and pass requests for real-time predictions and insights. Defaults to `false`. + * `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.