Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
make test
andmake lint
to ensure it passes unit and linter tests.Derived from GoogleCloudPlatform/magic-modules#7064