Courseiva

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?

⚠ Common exam trap

ACE often tests the exact gcloud command syntax for creating custom roles, and candidates may confuse it with service account creation or use incorrect command names like 'custom-roles'.

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 correct command to create a custom IAM role with specific permissions is 'gcloud iam roles create' with the --project flag and a comma-separated list of permissions. This creates a project-level custom role with exactly the permissions specified. The syntax matches the gcloud iam roles create command structure.

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.

About these practice questions

This ACE question is part of Courseiva's 775-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 →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Google Cloud exam blueprint

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.