Retrieve current OAuth access token from google_client_config data source #1277
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 pull request adds the field
access_token
to thegoogle_client_config
data source. The fieldaccess_token
provides the current OAuth2 token of the client which is used by the provider to authenticate against the Google Cloud API.I decided to add the field to the
google_client_config
since this data source refers to the provider client already instead of creating a separate data source. From a hypothetical data source such asgoogle_oauth_token
, I would expect that it creates a "fresh" token not used by the provider client and that it allows defining the scope.Use Case: GKE on GCP with Terraform
A particular use case is to allow the
terraform
provider to authenticate against a GKE cluster using the credentials already used by thegoogle
provider. The following example integrates both, thegoogle
and thekubernetes
provider in a single Terraform configuration to provision a GKE cluster and create a simple Kubernetes service while purely relying on Google IAM for authentication.I have added a shorter version of this use case as an example to the documentation of the
google_client_config
data source.