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

Host #5059

Conversation

modular-magician
Copy link
Collaborator

This PR is to fix hashicorp/terraform-provider-google#11365

Bugainzer issue : http://b/259900352

In Postgres and SQL Server, if the host is specified then the user is created by the API by ignoring the field.
In terraform, the resource ID is in the format of {user.Name/user.Host/user.Instance}.
The user.create function would set the host field in the resource ID using the value passed by the user, but the user.read function would set the host field of the resource ID as null after fetching the new user details from the API.

The error "Error: Provider produced inconsistent result after apply" is thrown due to the resource ID mismatch.

Solution (1) is to fix the ID mismatch problem, but still since the host field would be null after reading the user from the API. There would be a terraform drift due to the change in the value of "host" field in state file ("host value" --> null). In addition to that since host is a ForceNew field, if the customer removes the host field after seeing the terraform drift, the existing user would be deleted and recreated.

Hence the solution (2) is to validate that the host field is empty for Postgres and Sql Server users.

I have implemented solution (2).

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.
google_sql_user: added validation for host field.

Derived from GoogleCloudPlatform/magic-modules#7064

fix hashicorp/terraform-provider-google#11365

Signed-off-by: Modular Magician <magic-modules@google.com>
@modular-magician modular-magician merged commit 3ea6e9b into hashicorp:main Jan 7, 2023
@modular-magician modular-magician deleted the downstream-pr-ea95f14ff6dd9eb421297356238f0047544276b6 branch November 16, 2024 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant