IAM & Service Accounts
Google ACE ACE · Configuring access and security
IAM: who can do what
Identity and Access Management (IAM) is Google Cloud's access control system. It answers one question: which identity (a principal — a user, a group, a service account, or a domain) is allowed to do what (a role — a collection of permissions) on which resource? The binding of a principal to a role on a resource is stored in an IAM policy. Policies attach to any level of the resource hierarchy — organization, folder, project, or individual resource — and are inherited downward: a role granted on a folder applies to every project inside it. The exam tests IAM as the largest single security topic, and the core skill is choosing the narrowest role that still lets the principal do the job: least privilege.
Role types: basic, predefined, custom
Google Cloud has three kinds of roles. Basic roles are the legacy, coarse-grained roles: Owner (full control of a project, including billing and IAM), Editor (full control of resources but not IAM or billing), and Viewer (read-only access). They are too broad for most use and the exam treats them as the wrong answer whenever a narrower role exists — a question that offers Owner as an option is usually testing whether you pick something narrower. Predefined roles are Google-maintained roles for specific job functions, such as Compute Instance Admin, Storage Object Viewer, or BigQuery Data Editor. They follow least privilege by design and are the default correct answer for most access questions: find the predefined role that matches the task. Custom roles are roles you define yourself, picking exactly the permissions a job needs. They are the answer when no predefined role fits — for example, a support engineer who needs to view VM details and restart instances but not create or delete them. Custom roles are defined at the organization or project level and can include only the permissions you select.
Two more role concepts appear on the exam. Primitive roles is an older name for basic roles. And IAM policies support conditions: a binding can include a condition (such as "only during business hours" or "only for resources with a specific tag") that limits when the role applies. Conditions are the answer when a question asks for time-limited or resource-scoped access without creating a separate role.
IAM policies: viewing and managing
An IAM policy is a collection of bindings, and it can be viewed in the console (IAM page for a project, folder, or organization) or with gcloud projects get-iam-policy (and the equivalent commands for folders, organizations, and resources). Granting a role is gcloud projects add-iam-policy-binding or the console's Grant Access flow. The exam tests the mechanics lightly — mostly it tests which role to grant, at which level, and to which principal. Remember the inheritance rule: grant at the highest level that matches the scope (organization for company-wide admins, folder for a department, project for a team, resource for a single bucket or VM), and prefer groups over individual users.
Service accounts
A service account is an identity for a machine or an application, rather than a person. When an application running on a VM, in Cloud Run, or in GKE calls a Google Cloud API, it authenticates as a service account, and the roles granted to that service account decide what it can do. Every project has a default Compute Engine service account and a default App Engine service account, but best practice is to create dedicated service accounts per application with only the permissions that application needs. Service accounts are created in the console or with gcloud iam service-accounts create, and they are assigned to resources at creation (a VM's service account can be changed later, but only while the VM is stopped, in most cases).
Service accounts have their own IAM: you grant roles to a service account (what it can do), and you grant roles on a service account (who can use it). The key role for the second is Service Account User (iam.serviceAccountUser): a developer needs it on a service account before they can attach that account to a VM or run a job as it. The Service Account Token Creator role allows creating short-lived credentials for the account. Service account impersonation lets a principal temporarily act as a service account — obtaining short-lived credentials for it — without ever holding its key. Impersonation is the recommended pattern for a developer who needs to test something as the service account, or for a CI/CD pipeline that deploys as a service account: the human or pipeline authenticates as themselves, then impersonates the account for the duration of the task.
Keys and short-lived credentials
Service accounts can authenticate with keys (downloadable JSON files) or with short-lived credentials. Keys are long-lived: they work until deleted, they can be leaked, and managing them is a burden — the exam consistently treats keys as the weaker answer. Short-lived credentials (access tokens that expire, typically within an hour) are the recommended approach: they are obtained through impersonation, through the metadata server on a VM (applications on Google Cloud get tokens automatically from the metadata server), or through Workload Identity Federation, which lets workloads running outside Google Cloud (on AWS, on-premises, or in GitHub Actions) authenticate with short-lived tokens using their own identity provider — no service account key needed. If a question mentions an external workload accessing Google Cloud, Workload Identity Federation is the modern, keyless answer. The principle throughout is the same: avoid long-lived keys wherever a short-lived alternative exists.
Troubleshooting access: the Policy Troubleshooter
When access does not work as expected — a user gets "permission denied" on a resource they should be able to use — the IAM Policy Troubleshooter is the diagnostic tool. You enter the principal, the resource, and the permission, and the Troubleshooter traces the effective policy: which bindings grant the permission, whether any deny policy blocks it, and where in the hierarchy the relevant policy lives. It answers the two questions that matter in a troubleshooting scenario: does this principal have this permission, and if not, why not? The exam tests it as the first step in an access investigation, before changing any roles — because guessing at IAM changes can grant too much or break something else.
Two supporting tools complete the access-management picture. IAM Recommender analyzes actual usage and suggests least-privilege adjustments: roles that are granted but never used, or permissions that could be narrowed. Acting on its recommendations is the routine way to tighten access over time. Audit logs (Admin Activity logs, always enabled) record every IAM policy change — who granted which role to whom, and when — so any access change is traceable. Together, the Troubleshooter (why does this fail?), the Recommender (what can we tighten?), and the audit logs (who changed what?) cover the full lifecycle of access management, and the exam rewards knowing which tool answers which question.
Exam traps to watch for
- Granting a basic role (Owner/Editor/Viewer) when a predefined role fits: basic roles are almost always too broad.
- Creating a service account key when impersonation or Workload Identity Federation would work: keys are long-lived and leakable.
- Forgetting the Service Account User role: a developer cannot attach a service account to a VM without it.
- Granting roles to individual users instead of groups: groups scale, individual grants do not.
Practice questions
Test yourself on this guide. Answers are checked instantly, with a full explanation for each question.
Q1.A developer needs to view the details of Compute Engine VMs in a project, but must not be able to create, modify, or delete any resources. Which role should you grant?
Explanation: Compute Viewer is the predefined role that matches the requirement exactly: read-only access to Compute Engine resources. Owner and Editor are basic roles that grant far more than read access — Owner includes billing and IAM control. Compute Instance Admin allows creating and deleting instances, which the requirement forbids.
Exam objective: ACE exam guide 4.1: Managing IAM — managing the various role types (basic, predefined, custom)
Q2.A support engineer needs a combination of permissions that no predefined role provides: view VM details and restart instances, but not create or delete them. What should you do?
Explanation: Custom roles exist for exactly this situation: when no predefined role matches, you define a role with precisely the permissions the job needs — least privilege. Editor and Compute Instance Admin both grant more than required. A separate project does not solve the permission problem and fragments the environment.
Exam objective: ACE exam guide 4.1: Managing IAM — defining custom IAM roles
Q3.An application running on a Compute Engine VM needs to write objects to a specific Cloud Storage bucket and nothing else. What is the best approach?
Explanation: A dedicated service account with the narrowest role (Storage Object Creator) scoped to the single bucket follows least privilege, and the VM authenticates automatically with no key file. Granting Storage Admin at the organization level is vastly over-broad. A downloaded key is a long-lived credential that can leak. A public bucket removes all access control.
Exam objective: ACE exam guide 4.2: Managing service accounts — using service accounts in IAM policies with minimum permissions; assigning service accounts to resources
Q4.A developer wants to test a deployment script that runs as a service account, without downloading the service account's key. What should they do?
Explanation: Impersonation lets the developer temporarily act as the service account using short-lived credentials, with no key file involved — and the access can be revoked by removing the impersonation permission. Sharing a key creates a long-lived credential. The Owner role is unrelated to acting as a service account and is far too broad. A second service account does not solve the authentication problem.
Exam objective: ACE exam guide 4.2: Managing service accounts — managing service account impersonation; creating and managing short-lived service account credentials
Q5.A developer tries to create a VM using a specific service account, but receives a permission error even though they have the Compute Instance Admin role. What is the most likely missing permission?
Explanation: Attaching a service account to a resource requires the Service Account User role on that service account — it is a separate permission from creating the VM itself, and it is the classic missing piece in this scenario. Owner would work but is wildly over-broad. The service account's own roles control what the VM can do, not whether the developer can attach it. A key file is not needed to attach an account to a VM.
Exam objective: ACE exam guide 4.2: Managing service accounts — managing IAM of a service account
Q6.A CI/CD pipeline running in GitHub Actions needs to deploy to Google Cloud. The team wants to avoid storing a service account key in GitHub. What should they use?
Explanation: Workload Identity Federation lets external workloads (GitHub Actions, AWS, on-premises) authenticate to Google Cloud with short-lived tokens based on their own identity provider — no service account key is stored anywhere. A key in GitHub Secrets is the pattern the team wants to avoid. The default Compute Engine service account is for VMs, not external pipelines. A shared user account with Owner is a serious security failure.
Exam objective: ACE exam guide 4.2: Managing service accounts — creating and managing short-lived service account credentials
Q7.A contractor needs access to a project for two weeks only. After that, access must end automatically. What is the best approach?
Explanation: IAM conditions support time-based expiry: the binding includes a condition that stops applying after the specified date, so access ends automatically with no manual step to forget. A calendar reminder relies on a human remembering. A service account is for applications, not a human contractor. Owner is far too broad and does not expire.
Exam objective: ACE exam guide 4.1: Managing IAM — viewing and creating IAM policies
Q8.A company has 30 projects under a folder for the Finance department. The finance manager needs read-only access to all of them. What is the most efficient way to grant it?
Explanation: IAM roles granted on a folder are inherited by every project inside it, so a single grant covers all 30 projects — including any added later. Granting in each project is slow and error-prone. Organization Administrator is far too broad. A service account is for applications, not for a human manager.
Exam objective: ACE exam guide 4.1: Managing IAM — viewing and creating IAM policies