diff --git a/.changelog/3863.txt b/.changelog/3863.txt new file mode 100644 index 00000000000..c8222c02270 --- /dev/null +++ b/.changelog/3863.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +composer: added `database_config` and `web_server_config` to `google_composer_environment` resource (TPGB only) +``` diff --git a/google/resource_composer_environment.go b/google/resource_composer_environment.go index d25ce7ff6cb..10ab01fe7a9 100644 --- a/google/resource_composer_environment.go +++ b/google/resource_composer_environment.go @@ -589,6 +589,7 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{}) } d.SetPartial("config") } + } if d.HasChange("labels") { diff --git a/google/resource_composer_environment_test.go b/google/resource_composer_environment_test.go index 8032b85ea4c..2e98952184e 100644 --- a/google/resource_composer_environment_test.go +++ b/google/resource_composer_environment_test.go @@ -306,29 +306,29 @@ func testAccComposerEnvironmentDestroyProducer(t *testing.T) func(s *terraform.S func testAccComposerEnvironment_basic(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" - } - } + 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" + } + } } // 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 + 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 = "%s" + ip_cidr_range = "10.2.0.0/16" + region = "us-central1" + network = google_compute_network.test.self_link } `, name, network, subnetwork) } @@ -336,38 +336,38 @@ resource "google_compute_subnetwork" "test" { func testAccComposerEnvironment_private(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" - ip_allocation_policy { - use_ip_aliases = true - cluster_ipv4_cidr_block = "10.0.0.0/16" - } - } - private_environment_config { - enable_private_endpoint = true - } - } + 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" + ip_allocation_policy { + use_ip_aliases = true + cluster_ipv4_cidr_block = "10.0.0.0/16" + } + } + private_environment_config { + enable_private_endpoint = true + } + } } // 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 + 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 - private_ip_google_access = true + name = "%s" + ip_cidr_range = "10.2.0.0/16" + region = "us-central1" + network = google_compute_network.test.self_link + private_ip_google_access = true } `, name, network, subnetwork) } @@ -378,52 +378,52 @@ data "google_composer_image_versions" "all" { } resource "google_composer_environment" "test" { - name = "%s" - region = "us-central1" - - config { - node_count = 4 - node_config { - network = google_compute_network.test.self_link - subnetwork = google_compute_subnetwork.test.self_link - zone = "us-central1-a" - } + name = "%s" + region = "us-central1" + + config { + node_count = 4 + node_config { + network = google_compute_network.test.self_link + subnetwork = google_compute_subnetwork.test.self_link + zone = "us-central1-a" + } - software_config { - image_version = data.google_composer_image_versions.all.image_versions[0].image_version_id + software_config { + image_version = data.google_composer_image_versions.all.image_versions[0].image_version_id - airflow_config_overrides = { - core-load_example = "True" - } + airflow_config_overrides = { + core-load_example = "True" + } - pypi_packages = { - numpy = "" - } + pypi_packages = { + numpy = "" + } - env_variables = { - FOO = "bar" - } - } - } + env_variables = { + FOO = "bar" + } + } + } - labels = { - foo = "bar" - anotherlabel = "boo" - } + labels = { + foo = "bar" + anotherlabel = "boo" + } } // 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 + 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 = "%s" + ip_cidr_range = "10.2.0.0/16" + region = "us-central1" + network = google_compute_network.test.self_link } `, name, network, subnetwork) } @@ -431,41 +431,41 @@ resource "google_compute_subnetwork" "test" { func testAccComposerEnvironment_nodeCfg(environment, network, subnetwork, serviceAccount 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" - - service_account = google_service_account.test.name - } - } + 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" + + service_account = google_service_account.test.name + } + } - depends_on = [google_project_iam_member.composer-worker] + depends_on = [google_project_iam_member.composer-worker] } resource "google_compute_network" "test" { - name = "%s" - auto_create_subnetworks = false + 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 = "%s" + ip_cidr_range = "10.2.0.0/16" + region = "us-central1" + network = google_compute_network.test.self_link } resource "google_service_account" "test" { - account_id = "%s" - display_name = "Test Service Account for Composer Environment" + account_id = "%s" + display_name = "Test Service Account for Composer Environment" } resource "google_project_iam_member" "composer-worker" { - role = "roles/composer.worker" - member = "serviceAccount:${google_service_account.test.email}" + role = "roles/composer.worker" + member = "serviceAccount:${google_service_account.test.email}" } `, environment, network, subnetwork, serviceAccount) } @@ -476,33 +476,33 @@ data "google_composer_image_versions" "all" { } 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 = data.google_composer_image_versions.all.image_versions[0].image_version_id - python_version = "3" - } - } + 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 = data.google_composer_image_versions.all.image_versions[0].image_version_id + python_version = "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 + 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 = "%s" + ip_cidr_range = "10.2.0.0/16" + region = "us-central1" + network = google_compute_network.test.self_link } `, name, network, subnetwork) } @@ -510,34 +510,34 @@ resource "google_compute_subnetwork" "test" { func testAccComposerEnvironment_updateOnlyFields(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 { - pypi_packages = { - scipy = "==1.1.0" - } - } - } + 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 { + pypi_packages = { + scipy = "==1.1.0" + } + } + } } // 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 + 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 = "%s" + ip_cidr_range = "10.2.0.0/16" + region = "us-central1" + network = google_compute_network.test.self_link } `, name, network, subnetwork) } diff --git a/website/docs/r/composer_environment.html.markdown b/website/docs/r/composer_environment.html.markdown index 87f11f12b86..99136f3a03d 100644 --- a/website/docs/r/composer_environment.html.markdown +++ b/website/docs/r/composer_environment.html.markdown @@ -173,6 +173,13 @@ The `config` block supports: (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) The network-level access control policy for the Airflow web server. If unspecified, no network-level access restrictions will be applied. +* `database_config` - + (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) + The configuration settings for Cloud SQL instance used internally by Apache Airflow software. + +* `web_server_config` - + (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) + The configuration settings for the Airflow web server App Engine instance. The `node_config` block supports: @@ -369,6 +376,22 @@ The `ip_allocation_policy` block supports: (e.g. 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) to pick a specific range to use. Specify either `services_secondary_range_name` or `services_ipv4_cidr_block` but not both. +The `database_config` block supports: + +* `machine_type` - + (Required) + Cloud SQL machine type used by Airflow database. It has to be one of: db-n1-standard-2, + db-n1-standard-4, db-n1-standard-8 or db-n1-standard-16. + +The `web_server_config` block supports: + +* `machine_type` - + (Required) + Machine type on which Airflow web server is running. It has to be one of: composer-n1-webserver-2, + composer-n1-webserver-4 or composer-n1-webserver-8. + Value custom is returned only in response, if Airflow web server parameters were + manually changed to a non-standard values. + ## Attributes Reference