Google ACE Setting Up a Cloud Solution Environment Practice Question
You are managing a project and need to create a custom IAM role that allows only the permissions compute.instances.list and compute.instances.get. What is the correct way to create this role using gcloud?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
gcloud iam roles create viewer --project=my-project --permissions="compute.instances.list,compute.instances.get"
The command 'gcloud iam roles create' is used to create custom roles. The permissions are specified with the --permissions flag.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
gcloud iam service-accounts create viewer --permissions="compute.instances.list,compute.instances.get"
Why it's wrong here
This command misuses the service-accounts resource: a service account is an identity (a member) for APIs and workloads, not a container for permissions. Additionally, `gcloud iam service-accounts create` accepts no `--permissions` flag, so the command would fail with an unrecognized flag error. To grant permissions, you would create a custom IAM role via `gcloud iam roles create` and then bind it to a principal.
- ✗
gcloud iam roles create viewer --organization=123456 --permissions="compute.instances.*"
Why it's wrong here
This command targets the organization level instead of the project, and more critically uses a wildcard `*` in the permissions list. Custom IAM roles do not allow wildcards; every permission must be explicitly enumerated, so `compute.instances.*` is invalid and would be rejected by the API. Even if wildcards were allowed, it would grant every `compute.instances` permission, violating the principle of least privilege for a viewer role.
- ✓
gcloud iam roles create viewer --project=my-project --permissions="compute.instances.list,compute.instances.get"
Why this is correct
This is the correct command: `gcloud iam roles create` creates a custom role scoped to the specified project, and the `--permissions` flag explicitly lists the two required read-only permissions. Using specific permission names without wildcards enforces least privilege and aligns with IAM's requirement for fully qualified permission identifiers. The resulting role can then be bound to users or groups with `gcloud projects add-iam-policy-binding`.
- ✗
gcloud iam custom-roles create viewer --project=my-project --permissions='compute.instances.list,compute.instances.get'
Why it's wrong here
The `gcloud iam custom-roles create` subcommand does not exist in the Google Cloud CLI. The correct command group is `gcloud iam roles`, with the resource type `roles`; using a nonexistent verb yields an `ERROR: unknown command` message. The single quotes around the permissions are syntactically valid in a shell, but the command itself is fatally wrong because of the invalid subcommand path.
Go deeper
Related to this question
Learn chapter
Google Compute Engine
Key term
IAM role
An IAM role is a set of permissions that an entity can assume temporarily to access cloud resources securely.
Key term
IAM
Identity and Access Management (IAM) is a framework of policies and technologies that ensures the right individuals have the appropriate access to technology resources.
About these practice questions
This ACE question is part of Courseiva's 769-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This ACE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the ACE exam.