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

Make cloud composer environment image version updateable. #1755

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
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
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,10 @@ resource "google_composer_environment" "test" {
node_count = 4

software_config {
<% unless version == 'ga' -%>
image_version = "composer-1.7.0-airflow-1.10.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry I didn't catch this earlier- this also needs beta-only guards, since without it the test in the GA provider will destroy/create instead of doing an update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

<% end -%>

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