Imad
Imad

Reputation: 2741

How to upgrade/update minor version of composer via Terraform?

I just recently created on my terraform base module a composer environment instance (resource google_composer_environment) with the following attribute : image_version = "composer-2.0.30-airflow-2.3.3".

When you try to upgrade via the console, the cluster is not destroyed (I think?), but when I try to do it via terraform using image_version = "composer-2.0.32-airflow-2.3.4" the environment will apparently be scrapped and recreated :

# module.dev-omni-orchestrator-instance.google_composer_environment.omni-orchestrator-instance must be replaced
...
Plan: 1 to add, 0 to change, 1 to destroy.

Is there a way to achieve these version upgrade within terraform without destroying the existing environment? Perhaps upgrade via the console or gcloud and then update+import somehow?

Upvotes: 1

Views: 910

Answers (2)

Krisztian
Krisztian

Reputation: 139

The in-place upgrade can be done with the google-beta provider currently.

Check the comment here: https://github.com/hashicorp/terraform-provider-google/issues/10331#issuecomment-1781694243

Upvotes: 1

Mazlum Tosun
Mazlum Tosun

Reputation: 6572

I had the same issue previously, to solve it :

  • Upgrade the version from the Cloud Composer console, in this case the cluster will not be destroyed
  • Upgrade the version in your Terraform code
  • When you will plan your Terraform Composer resource, Terraform will detect a change in the real infrastructure and will no plan change and nothing to update (because the version from the real infra is the same than in the Terraform resource)

I think it's an issue of the resource in the Google provider but it was not blocking for me with this technique.

Upvotes: 5

Related Questions