Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow updates to composer webserver and database. #2491

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3953.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
composer: allow in-place updates to webserver and database machine type
```
10 changes: 4 additions & 6 deletions google-beta/resource_composer_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ func resourceComposerEnvironment() *schema.Resource {
"machine_type": {
Type: schema.TypeString,
Required: true,
ForceNew: 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.`,
},
},
Expand All @@ -418,7 +417,6 @@ func resourceComposerEnvironment() *schema.Resource {
"machine_type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `Optional. 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. If not specified, composer-n1-webserver-2 will be used. Value custom is returned only in response, if Airflow web server parameters were manually changed to a non-standard values.`,
},
},
Expand Down Expand Up @@ -662,24 +660,24 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{})
d.SetPartial("config")
}

if d.HasChange("config.0.database_config") {
if d.HasChange("config.0.database_config.0.machine_type") {
patchObj := &composer.Environment{Config: &composer.EnvironmentConfig{}}
if config != nil {
patchObj.Config.DatabaseConfig = config.DatabaseConfig
}
err = resourceComposerEnvironmentPatchField("config.databaseConfig", patchObj, d, tfConfig)
err = resourceComposerEnvironmentPatchField("config.databaseConfig.machineType", patchObj, d, tfConfig)
if err != nil {
return err
}
d.SetPartial("config")
}

if d.HasChange("config.0.web_server_config") {
if d.HasChange("config.0.web_server_config.0.machine_type") {
patchObj := &composer.Environment{Config: &composer.EnvironmentConfig{}}
if config != nil {
patchObj.Config.WebServerConfig = config.WebServerConfig
}
err = resourceComposerEnvironmentPatchField("config.webServerConfig", patchObj, d, tfConfig)
err = resourceComposerEnvironmentPatchField("config.webServerConfig.machineType", patchObj, d, tfConfig)
if err != nil {
return err
}
Expand Down