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

Add a datasource for retrieving the client email from OpenID Connect #1422

Conversation

rileykarson
Copy link
Member

Alright, so this one is a bit of a departure from our regularly scheduled programming. This isn't a GCP API, but is a Google API.

We have no way right now to tell what account email is being used to interact with GCP; this is especially important when using Terraform in a CI system and the user hasn't manually defined their service account.

Provided the user has specified the necessary oauth scope, datasource uses a well-known OpenID / Oauth2 endpoint we [Google] publish to retrieve the email tied to the user's credentials.

While getting this normally isn't important for interacting with GCP- GCP is already able to tell your email even w/o the scope- it is important at the crossover point from GKE -> K8S when using OpenID auth; to bootstrap K8S inside a GKE cluster, users using the recommended auth system (OpenID/IAM auth) need to define rolebindings against their GCP email.

So, instead of requiring that to be defined by hand, this datasource lets us figure that out in the Google provider and pass that information on into the rest of our Terraform config.


[all]

[terraform]

[terraform-beta]

[ansible]

[inspec]

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
This PR seems not to have generated downstream PRs before, as of b26702e.

Pull request statuses

No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed.
depends: hashicorp/terraform-provider-google-beta#459
depends: hashicorp/terraform-provider-google#3103

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 90bb6b2.

Pull request statuses

terraform-provider-google-beta already has an open PR.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@paddycarver
Copy link
Contributor

I'm leery of this, but open to being pragmatic about it. I dislike adding non-GCP resources, because people are going to want to expand our scope to include all sorts of things, and our answer has always been it's a GCP-specific provider.

The purist answer is a separate provider should be made, maybe an OpenID provider or a Google Identity provider or something.

But all my arguments are around precedents, and I'm not sure I want precedents to stand in the way of user benefits.

Copy link
Contributor

@paddycarver paddycarver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤞 let's do this.

@modular-magician modular-magician force-pushed the datasource-openid-userinfo branch from 90bb6b2 to f722077 Compare February 25, 2019 20:43
@modular-magician modular-magician merged commit eb4cd82 into GoogleCloudPlatform:master Feb 25, 2019

subject {
kind = "User"
name = "${data.google_client_openid_useremail.provider_identity.email}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants