Skip to main content

IAM Component

The IAM component creates service accounts and assigns roles for secure access to GCP resources.

Service Accounts

Service AccountPurpose
app@project.iamApplication workloads in GKE
gke-nodes@project.iamGKE node pool identity
cicd@project.iamCI/CD pipeline deployments
langfuse@project.iamObservability service

Architecture

Role Assignments

Application Service Account (app)

Used by backend pods via Workload Identity:

RolePurpose
secretmanager.secretAccessorRead secrets
storage.objectAdminAccess app data buckets
cloudsql.clientConnect to databases

GKE Nodes Service Account (gke-nodes)

Used by GKE node pools:

RolePurpose
artifactregistry.readerPull container images
logging.logWriterWrite logs to Cloud Logging
monitoring.metricWriterWrite metrics

CI/CD Service Account (cicd)

Used by deployment pipelines:

RolePurpose
artifactregistry.writerPush container images
container.developerDeploy to GKE
storage.objectAdminUpload static assets

Langfuse Service Account (langfuse)

Used by observability service:

RolePurpose
storage.objectAdminWrite to langfuse bucket

Workload Identity

Workload Identity federates Kubernetes and GCP identities:

Configuration

  1. Kubernetes ServiceAccount with annotation:
apiVersion: v1
kind: ServiceAccount
metadata:
name: backend
namespace: default
annotations:
iam.gke.io/gcp-service-account: app@PROJECT_ID.iam.gserviceaccount.com
  1. IAM Binding for Workload Identity:
new gcp.serviceaccount.IAMMember('workload-identity-binding', {
serviceAccountId: appServiceAccount.name,
role: 'roles/iam.workloadIdentityUser',
member: pulumi.interpolate`serviceAccount:${projectId}.svc.id.goog[NAMESPACE/KSA_NAME]`,
});

Outputs

interface IamOutputs {
appServiceAccountEmail: string;
gkeNodesServiceAccountEmail: string;
cicdServiceAccountEmail: string;
langfuseServiceAccountEmail?: string;
}

Security Best Practices

Principle of Least Privilege

Each service account has only the roles required for its function:

  • App SA cannot push images
  • CI/CD SA cannot read secrets
  • Node SA can only read images

No Key Export

Service accounts use:

  • Workload Identity for GKE pods
  • Attached Service Account for CI/CD
  • No long-lived JSON keys in production

Audit Logging

All service account actions are logged in Cloud Audit Logs for compliance and security monitoring.