hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.26k stars 1.71k forks source link

Remove composer version validation regexp and diff suppress #11441

Open rileykarson opened 2 years ago

rileykarson commented 2 years ago

The google_composer_environment resource has a validation regexp paired with a DSF with an extreme burden of maintenance to keep up-to-date. We've had to update it numerous times (I count ~5 separate changes in history), as it often falls out of date with changes to the format of the version string in the API. Also of note- it's a single string tracking two versions.

Originally added due to a failing test (https://github.com/GoogleCloudPlatform/magic-modules/pull/1120) this regexp effectively allows users to specify "latest" as a version, and the API will (reasonably) return the realized version their environment was set to.

The results can also be confusing as users' configs will say latest, but Terraform will dismiss the diff even if the version is not the latest one. While we could remove the validation and keep the DSF, and that's likely a minor improvement, it will increase the number of cases where users have specified a version that creates a permadiff, requiring lifecycle.ignore_changes to resolve.

My proposal is that we remove both the DSF and the validation, and allow users to specify free-form values in the field. We'll recommend in our documentation that users do not use latest, and always find an appropriate version themselves. If they want to use it, they can use lifecycle.prevent_changes on the field. NOTE: Any canonicalization performed by the API will have a dangerous diff, threatening to recreate users' environments if approved w/o using lifecycle.prevent_destroy.

As discussed in https://github.com/GoogleCloudPlatform/magic-modules/pull/1120#discussion_r244789058, an API to return the latest version like is available in GKE would help mitigate the negative user experience.

b/349151248

sandy-0007 commented 2 years ago

@rileykarson Do you have a ETA to get this code fixed?

rileykarson commented 2 years ago

Do you have a ETA to get this code fixed?

See the other bug, which covers what I believe will resolve your issue.

In the meanwhile, could you please share me the earlier version of the provider which isn't affected by this REGEX change, so I could continue my deployment as temporary solution?

I don't know offhand- it's probably in 1.X or 2.X, we've had those since forever. The regex treadmill in https://github.com/hashicorp/terraform-provider-google/issues/11432#issuecomment-1092098002 is that we keep having to make it more permissive as the API adopts new formats, not that the regex is getting updated to be more restrictive.

sandy-0007 commented 2 years ago

Updating to the previous version of the provider had worked for me.

required_providers { google-beta = ">=3.43.0" google = ">=3.70.0, < 4.15.0"

roaks3 commented 1 month ago

This needs a more granular type for our forwarder. While it looks like we aim to resolve some tech debt here, I'm going to assume that a feature-request is the best choice, due to the user impact being a less error-prone solution.