diff --git a/.changelog/9468.txt b/.changelog/9468.txt new file mode 100644 index 0000000000..dde7284ab4 --- /dev/null +++ b/.changelog/9468.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +composer: added `database_config.zone` field in `google_composer_environment` +``` diff --git a/google-beta/services/composer/resource_composer_environment.go b/google-beta/services/composer/resource_composer_environment.go index 349ae1547e..b6cf8a7362 100644 --- a/google-beta/services/composer/resource_composer_environment.go +++ b/google-beta/services/composer/resource_composer_environment.go @@ -571,9 +571,15 @@ func ResourceComposerEnvironment() *schema.Resource { Schema: map[string]*schema.Schema{ "machine_type": { Type: schema.TypeString, - Required: true, + Optional: true, Description: `Optional. 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. If not specified, db-n1-standard-2 will be used.`, }, + "zone": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: `Optional. Cloud SQL database preferred zone.`, + }, }, }, }, @@ -1429,6 +1435,7 @@ func flattenComposerEnvironmentConfigDatabaseConfig(databaseCfg *composer.Databa transformed := make(map[string]interface{}) transformed["machine_type"] = databaseCfg.MachineType + transformed["zone"] = databaseCfg.Zone return []interface{}{transformed} } @@ -1840,6 +1847,7 @@ func expandComposerEnvironmentConfigDatabaseConfig(v interface{}, d *schema.Reso transformed := &composer.DatabaseConfig{} transformed.MachineType = original["machine_type"].(string) + transformed.Zone = original["zone"].(string) return transformed, nil } diff --git a/google-beta/services/composer/resource_composer_environment_test.go b/google-beta/services/composer/resource_composer_environment_test.go index 6ad2a4f195..1b1caa7f50 100644 --- a/google-beta/services/composer/resource_composer_environment_test.go +++ b/google-beta/services/composer/resource_composer_environment_test.go @@ -1753,6 +1753,9 @@ resource "google_composer_environment" "test" { memory_gb = 2.0 count = 1 } + } + database_config { + zone = "us-east1-c" } environment_size = "ENVIRONMENT_SIZE_MEDIUM" private_environment_config { diff --git a/website/docs/r/composer_environment.html.markdown b/website/docs/r/composer_environment.html.markdown index 907ec29f29..f50f286f42 100644 --- a/website/docs/r/composer_environment.html.markdown +++ b/website/docs/r/composer_environment.html.markdown @@ -569,10 +569,14 @@ The `web_server_network_access_control` supports: 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, + (Optional) + Optional. 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. +* `Zone` - + (Optional) + Preferred Cloud SQL database zone. + The `web_server_config` block supports: * `machine_type` -