Skip to content

Commit

Permalink
Add Terraform Support For Cloud SQL Preferred Zone Selection Feature …
Browse files Browse the repository at this point in the history
…(#9468) (#6653)

* Adding Support for zone selection after api changed

* Fixed build error

* Fixed documentation

---------


[upstream:bc77da041b3075c7d39e0f617a5e68919822fc85]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Nov 16, 2023
1 parent 9f642e6 commit a6d2dbb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/9468.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
composer: added `database_config.zone` field in `google_composer_environment`
```
10 changes: 9 additions & 1 deletion google-beta/services/composer/resource_composer_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
},
},
},
},
Expand Down Expand Up @@ -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}
}
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions website/docs/r/composer_environment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,14 @@ The `web_server_network_access_control` supports:
<a name="nested_database_config"></a>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.

<a name="nested_web_server_config"></a>The `web_server_config` block supports:

* `machine_type` -
Expand Down

0 comments on commit a6d2dbb

Please sign in to comment.