Skip to content

Commit

Permalink
Make cloud composer environment image version updateable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarp committed May 28, 2019
1 parent 5a866ab commit ef87d27
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ func resourceComposerEnvironment() *schema.Resource {
Computed: true,
<% unless version == 'ga' -%>
Optional: true,
ForceNew: true,
ValidateFunc: validateRegexp(composerEnvironmentVersionRegexp),
DiffSuppressFunc: composerImageVersionDiffSuppress,
},
Expand Down Expand Up @@ -333,8 +332,25 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{})
return err
}

if d.HasChange("config.0.software_config.0.airflow_config_overrides") {
<% unless version == 'ga' -%>
if d.HasChange("config.0.software_config.0.image_version") {
patchObj := &composer.Environment{
Config: &composer.EnvironmentConfig{
SoftwareConfig: &composer.SoftwareConfig{},
},
}
if config != nil && config.SoftwareConfig != nil {
patchObj.Config.SoftwareConfig.ImageVersion = config.SoftwareConfig.ImageVersion
}
err = resourceComposerEnvironmentPatchField("config.softwareConfig.imageVersion", patchObj, d, tfConfig)
if err != nil {
return err
}
d.SetPartial("config")
}
<% end -%>

if d.HasChange("config.0.software_config.0.airflow_config_overrides") {
patchObj := &composer.Environment{
Config: &composer.EnvironmentConfig{
SoftwareConfig: &composer.SoftwareConfig{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ func testAccComposerEnvironmentDestroy(s *terraform.State) error {
func testAccComposerEnvironment_basic(name string) string {
return fmt.Sprintf(`
resource "google_composer_environment" "test" {
name = "%s"
region = "us-central1"
name = "%s"
region = "us-central1"
}
`, name)
}
Expand All @@ -295,6 +295,8 @@ resource "google_composer_environment" "test" {
node_count = 4

software_config {
image_version = "composer-1.7.0-airflow-1.10.2"

airflow_config_overrides = {
core-load_example = "True"
}
Expand Down

0 comments on commit ef87d27

Please sign in to comment.