diff --git a/mmv1/third_party/terraform/resources/resource_composer_environment.go.erb b/mmv1/third_party/terraform/resources/resource_composer_environment.go.erb index f834a441d982..a06ca183de29 100644 --- a/mmv1/third_party/terraform/resources/resource_composer_environment.go.erb +++ b/mmv1/third_party/terraform/resources/resource_composer_environment.go.erb @@ -883,6 +883,21 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{}) } <% end -%> + if d.HasChange("config.0.software_config.0.scheduler_count") { + patchObj := &composer.Environment{ + Config: &composer.EnvironmentConfig{ + SoftwareConfig: &composer.SoftwareConfig{}, + }, + } + if config != nil && config.SoftwareConfig != nil { + patchObj.Config.SoftwareConfig.SchedulerCount = config.SoftwareConfig.SchedulerCount + } + err = resourceComposerEnvironmentPatchField("config.softwareConfig.schedulerCount", userAgent, patchObj, d, tfConfig) + if err != nil { + return err + } + } + if d.HasChange("config.0.software_config.0.airflow_config_overrides") { patchObj := &composer.Environment{ Config: &composer.EnvironmentConfig{ diff --git a/mmv1/third_party/terraform/tests/resource_composer_environment_test.go.erb b/mmv1/third_party/terraform/tests/resource_composer_environment_test.go.erb index 941b1023f47f..dbf5bf90740e 100644 --- a/mmv1/third_party/terraform/tests/resource_composer_environment_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_composer_environment_test.go.erb @@ -718,6 +718,14 @@ func TestAccComposerEnvironmentAirflow2_withSoftwareConfig(t *testing.T) { { Config: testAccComposerEnvironment_airflow2SoftwareCfg(envName, network, subnetwork), }, + { + ResourceName: "google_composer_environment.test", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccComposerEnvironmentUpdate_airflow2SoftwareCfg(envName, network, subnetwork), + }, { ResourceName: "google_composer_environment.test", ImportState: true, @@ -729,7 +737,7 @@ func TestAccComposerEnvironmentAirflow2_withSoftwareConfig(t *testing.T) { { PlanOnly: true, ExpectNonEmptyPlan: false, - Config: testAccComposerEnvironment_airflow2SoftwareCfg(envName, network, subnetwork), + Config: testAccComposerEnvironmentUpdate_airflow2SoftwareCfg(envName, network, subnetwork), Check: testAccCheckClearComposerEnvironmentFirewalls(t, network), }, }, @@ -1716,6 +1724,40 @@ resource "google_compute_subnetwork" "test" { `, name, network, subnetwork) } +func testAccComposerEnvironmentUpdate_airflow2SoftwareCfg(name, network, subnetwork string) string { + return fmt.Sprintf(` +resource "google_composer_environment" "test" { + name = "%s" + region = "us-central1" + config { + node_config { + network = google_compute_network.test.self_link + subnetwork = google_compute_subnetwork.test.self_link + zone = "us-central1-a" + } + software_config { + image_version = "composer-1-airflow-2" + scheduler_count = 3 + } + } +} + +// use a separate network to avoid conflicts with other tests running in parallel +// that use the default network/subnet +resource "google_compute_network" "test" { + name = "%s" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "test" { + name = "%s" + ip_cidr_range = "10.2.0.0/16" + region = "us-central1" + network = google_compute_network.test.self_link +} +`, name, network, subnetwork) +} + /** * CLEAN UP HELPER FUNCTIONS * Because the environments are flaky and bucket deletion rates can be