Connect Google Cloud
Let kosem act as one or more service accounts of yours, with no key, so that access profiles can issue short-lived Google Cloud access tokens.
Connect a Google Cloud project or organization through workload identity federation: a service account of yours trusts kosem's identity tokens for this one connection, and kosem keeps no key. You can add up to 20 service accounts on the same connection. Access profiles then issue short-lived access tokens for one of those accounts, lasting up to an hour. To do it, you need Owner or Connection Admin on the kosem organization, or on the project for a project's own connection, and, in Google Cloud, permission to create a workload identity pool, a service account and its role bindings.
Create the connection
- In your organization, click Access, then Connections.
- Click Connect an account, and select Google Cloud.
- Optionally, enter a Name (optional), and under Share with, select the projects that can use it.
- Click Continue.
kosem creates the connection, which needs attention until Google Cloud trusts it, and opens its page.
To connect an account for one project alone, start in the project instead: click Access, then Connections, then Connect an account, and select Google Cloud. The project's own connection isn't shared with other projects. If the page says a policy keeps projects from connecting accounts of their own, your organization turned on Turn off projects' own connections.
Set up the trust in Google Cloud
On the connection's page, under Trust in Google Cloud:
- Enter the Google Cloud project that holds the workload identity pool and the service account, such as
acme-prod. To reach a whole organization, use a project of its own for this. - Under Reach, select This project, or The whole organization and enter its Organization ID.
- Under Role, select what the service account can do there: Viewer, Editor, or None: I'll grant roles myself. Its roles are all that tokens can do.
- Copy the commands from the gcloud tab, and run them in a terminal signed in to Google Cloud, or click Open Cloud Shell. The Terraform tab has the same as Terraform.
The commands create a workload identity pool and a provider that takes kosem's identity tokens for your organization's connections, and a service account that only this connection's subject can act as. They print two values.
The provider's condition, assertion.org == '…', takes your organization's connections and its projects' own alike, so one provider can serve them all. A project's connection gets a provider of its own in the same pool, since a provider set up before projects had connections of their own took only the organization's. To use that one for projects too, widen its condition to the one the page shows now.
If an organization policy blocks the provider, ask your Google Cloud administrator to allow kosem's issuer in iam.managed.workloadIdentityPoolProviders.
Finish setup
- Enter the two values the commands printed: Workload identity provider and Service account.
- Click Finish setup.
kosem signs in as the service account to check the trust. It also checks that Google Cloud refuses other identities, such as another connection's, and refuses a trust that takes them. Google Cloud can take a few minutes to apply new trust: if it refuses at first, wait and try again.
Once it's connected, create an access profile that issues its tokens.