Skip to content

Instantly share code, notes, and snippets.

@EronWright
Created February 14, 2020 04:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save EronWright/039192b4e7a4e53828cda0e76e3a0498 to your computer and use it in GitHub Desktop.
Save EronWright/039192b4e7a4e53828cda0e76e3a0498 to your computer and use it in GitHub Desktop.
Pulumi example for GKE Workload Identity
/*
Creates a GCP service account named 'test-workload-identity' to be used
by a GKE workload using a Kubernetes service account named 'default/default'.
*/
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const gcpConfig = new pulumi.Config("gcp");
const projectId = gcpConfig.get("project");
const ksa = "default/default";
const gsaName = "test-workload-identity";
const gsa = new gcp.serviceAccount.Account(gsaName, {
accountId: gsaName,
displayName: "An account for testing the GKE workload identity feature",
});
const binding = new gcp.serviceAccount.IAMBinding(`${gsaName}:${ksa}`, {
serviceAccountId: pulumi.interpolate `projects/${projectId}/serviceAccounts/${gsa.email}`,
members: [`serviceAccount:${projectId}.svc.id.goog[${ksa}]`],
role: "roles/iam.workloadIdentityUser"
});
@luillyfe
Copy link

you got a typo in serviceAccount, it must be:

new gcp.serviceaccount.IAMBinding

notice account must be lowercase. Anyway, thank you so mush, this is exactly what I was looking for.

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