Terraform-Provider-Google uses custom tokenSource logic that does not support OAuth over mTLS #14411
Labels
persistent-bug
Hard to diagnose or long lived bugs for which resolutions are more like feature work than bug work
size/s
Milestone
Community Note
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.Terraform Version
Terraform v1.5.0-dev
on linux_amd64
Affected Resource(s)
google_*
Terraform Configuration Files
Expected Behavior
Running terraform apply should successfully create pubsub topic.
Actual Behavior
Running terraform apply results in 403 forbidden in OAuth token exchange step.
Steps to Reproduce
terraform apply
Important Factoids
TL:DR This issue only impacts users who are a part of a CAA-policy group that requires all access to GCP APIs to have mTLS enabled, including oauth2 token exchange API. (This group is currently a small subset of GCP developers working on CAA-policy rollout at Google)
Backaground:
The Certificate Based Access team is working on rolling out a CAA policy for Googlers (starting with a subset of gcloud users) that would require them to use mTLS-enabled client tools to access all GCP APIs - this includes the OAuth2 token exchange API (a new requirement). The original mTLS-support for resource APIs was added to terraform ~2 years ago via the transport stack of google-api-go-client. However, the OAuth2 stack uses a separate HTTPClient (configurable via context key oauth2.HTTPClient), which does not have mTLS-support enabled. I authored PR 1886 to fix this problem for google-api-go-client, expecting this to fix the issue for terraform as well. However, it turns out that terraform injects a custom TokenSource and Credentials logic that effectively overrides the mTLS-enabled TokenSource logic provided by google-api-go-client. And upon further digging, it appears that terraform has a duplicate version of the credentials and ADC logic (application default credentials) .
Proposed Solution:
Remove the custom TokenSource logic in Terraform-google-provider and use default TokenSource logic provided by google-api-go-client. Since both code-paths are Google-specific credentials logic, they should be consolidated to not only fix this mTLS bug, but also to provide a consistent user experience w.r.t. supported credential types and order of priority. Steps:
References
The text was updated successfully, but these errors were encountered: