Do not set header X-Goog-User-Project header for the resource google_client_openid_userinfo #13474
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.
Fixes #10260
https://b.corp.google.com/issues/202287364
When the environment variable USER_PROJECT_OVERRIDE is set to true and GOOGLE_BILLING_PROJECT is set to some project, first the header X-Goog-User-Project is set in provider config.
https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/third_party/terraform/utils/config.go.erb#L307-L311
When the header X-Goog-User-Project is set for the call to get user info, it returns an error. Maybe the API openidconnect.googleapis.com does not handle the header X-Goog-User-Project properly. The error does not occur with other APIs. So don't set the header
X-Goog-User-Project
for the resource google_client_openid_userinfo.To not set header X-Goog-User-Project for the resource google_client_openid_userinfo, we need to override the header value in the resource level. First pass the project as "NO_BILLING_PROJECT_OVERRIDE" when calling sendRequest inside the function GetCurrentUserEmail. And inside sendRequest function, the header
X-Goog-User-Project
is set to empty string by checking the project value.The previous PR is reverted because if breaks some resources.
Feel free to add comment if you have any concerns about this solution.
If this PR is for Terraform, I acknowledge that I have:
-[X] 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).
make test
andmake lint
to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)
Derived from GoogleCloudPlatform/magic-modules#7113