The IAM Question
IAM answers: who (principal) can do what (role) on which resource. In Google Cloud this is written as a binding in an allow policy.
Principals (Who)
| Type | Example | Use |
|---|---|---|
| Google account / user | user:asha@example.com | A person |
| Group | group:devs@example.com | Best way to give access to teams |
| Service account | serviceAccount:app@proj.iam.gserviceaccount.com | An identity for an application or VM |
| Domain | domain:example.com | Everyone in a domain |
| Workforce / workload identity pool | Federated identities | External IdP users or other clouds |
Roles (What)
| Role type | Description | Advice |
|---|---|---|
| Basic | Owner, Editor, Viewer. Very broad | Avoid in production |
| Predefined | Created by Google per product, for example roles/storage.objectViewer | Prefer these |
| Custom | You pick exact permissions | Use when predefined is too wide |
- A permission is one action, for example
storage.objects.get - A role is a bundle of permissions
- Use the IAM Recommender to find unused permissions and shrink roles
Inheritance
Policies set at the organization or folder flow down to projects and resources. Give access at the lowest level that works.
Service Accounts
- A service account is an identity for code, not a person
- Attach it to a VM, Cloud Run service or GKE workload so apps get temporary credentials automatically
- Create one service account per application with only the roles it needs
- A service account is also a resource: people need
roles/iam.serviceAccountUserto attach it, androles/iam.serviceAccountTokenCreatorto impersonate it
Workload Identity Federation
Lets GitHub Actions, AWS, Azure or any OIDC/SAML provider call Google Cloud with a short-lived token without a key file. On GKE, Workload Identity links a Kubernetes service account to a Google service account.
Conditions and Deny
- IAM Conditions: grant a role only when a rule is true, for example before an expiry time or on resources with a tag
- Deny policies: block selected permissions even if a role grants them (guardrails)
- Privileged Access Manager: just-in-time elevated access with approvals
Best Practices
- Use groups, not individuals
- Use predefined roles, avoid Owner and Editor
- Grant at the lowest level possible
- One service account per workload, no keys
- Turn on audit logs and review with Recommender
- Separate duties: the person who deploys is not the person who approves
Practice
- Give a group Storage Object Viewer on one bucket only
- Create a service account and attach it to a VM
- Use
gcloud projects get-iam-policyto list who has Owner - Write a custom role with only three permissions
Conclusion
IAM binds principals to roles on resources and policies inherit down the hierarchy. Prefer groups, predefined roles, attached service accounts and Workload Identity Federation, and avoid basic roles and key files.

