Bird
Raised Fist0
GCPcloud~10 mins

Why IAM is foundational in GCP - Test Your Understanding

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to assign a role to a user in GCP IAM.

GCP
gcloud projects add-iam-policy-binding my-project --member='user:alice@example.com' --role=[1]
Drag options to blanks, or click blank then click option'
Aroles/storage.admin
Broles/viewer
Croles/owner
Droles/editor
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing roles/owner grants too many permissions.
Using roles/storage.admin is specific to storage only.
2fill in blank
medium

Complete the code to list IAM policies for a project.

GCP
gcloud projects get-iam-policy my-project --format=[1]
Drag options to blanks, or click blank then click option'
Atable
Byaml
Ctext
Djson
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'table' or 'text' formats which are less structured.
Choosing 'yaml' which is valid but less common for IAM policies.
3fill in blank
hard

Fix the error in the command to remove a role binding from a user.

GCP
gcloud projects remove-iam-policy-binding my-project --member=[1] --role=roles/editor
Drag options to blanks, or click blank then click option'
Auser:alice@example.com
Balice@example.com
Cuser alice@example.com
Duser=alice@example.com
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting 'user:' prefix causes errors.
Using '=' or spaces instead of ':'.
4fill in blank
hard

Fill both blanks to create a custom IAM role with permissions.

GCP
gcloud iam roles create myCustomRole --project=my-project --title='Custom Role' --permissions=[1] --stage=[2]
Drag options to blanks, or click blank then click option'
Acompute.instances.get,storage.buckets.list
Bstorage.objects.create,storage.objects.delete
CGA
DBETA
Attempts:
3 left
💡 Hint
Common Mistakes
Using permissions unrelated to the task.
Choosing 'BETA' stage for a stable role.
5fill in blank
hard

Fill all three blanks to grant a service account access to a BigQuery dataset.

GCP
gcloud projects add-iam-policy-binding my-project --member=[1] --role=[2] --condition=true --condition-title=[3]
Drag options to blanks, or click blank then click option'
AserviceAccount:my-service-account@my-project.iam.gserviceaccount.com
Broles/bigquery.dataViewer
C"Access BigQuery Dataset"
Duser:alice@example.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using a user instead of a service account.
Choosing a role with too many permissions.
Omitting quotes around the condition title.

Practice

(1/5)
1. What is the main purpose of IAM in Google Cloud Platform?
easy
A. To monitor network traffic
B. To store data securely in the cloud
C. To create virtual machines automatically
D. To control who can access and manage cloud resources

Solution

  1. Step 1: Understand IAM's role in GCP

    IAM stands for Identity and Access Management, which controls user permissions.
  2. Step 2: Identify the main function

    IAM manages who can access and change cloud resources, ensuring security and organization.
  3. Final Answer:

    To control who can access and manage cloud resources -> Option D
  4. Quick Check:

    IAM controls access = C [OK]
Hint: IAM is about access control, not storage or monitoring [OK]
Common Mistakes:
  • Confusing IAM with data storage services
  • Thinking IAM manages network traffic
  • Assuming IAM creates resources automatically
2. Which of the following is the correct way to assign a role to a user in GCP IAM?
easy
A. Grant the user a role using the IAM policy binding
B. Add the user to a Compute Engine instance
C. Create a new virtual machine for the user
D. Enable billing for the user account

Solution

  1. Step 1: Review how roles are assigned in IAM

    Roles are assigned by adding users to IAM policy bindings on resources.
  2. Step 2: Identify the correct method

    Granting a role via IAM policy binding is the proper way to assign permissions.
  3. Final Answer:

    Grant the user a role using the IAM policy binding -> Option A
  4. Quick Check:

    Role assignment = IAM policy binding [OK]
Hint: Roles are assigned via IAM policies, not VM or billing settings [OK]
Common Mistakes:
  • Confusing user role assignment with VM creation
  • Thinking billing enables permissions
  • Adding users directly to instances instead of IAM
3. Consider this IAM policy snippet:
{
  "bindings": [
    {
      "role": "roles/storage.objectViewer",
      "members": ["user:alice@example.com"]
    }
  ]
}

What permission does Alice have?
medium
A. She can delete storage objects
B. She can create new storage buckets
C. She can view objects in Cloud Storage buckets
D. She can manage billing for storage

Solution

  1. Step 1: Identify the role in the policy

    The role is "roles/storage.objectViewer", which grants read-only access to storage objects.
  2. Step 2: Understand the permissions of the role

    This role allows viewing objects but not creating or deleting them.
  3. Final Answer:

    She can view objects in Cloud Storage buckets -> Option C
  4. Quick Check:

    objectViewer means read-only access [OK]
Hint: Viewer roles allow read-only access, not changes [OK]
Common Mistakes:
  • Assuming viewer role allows object creation or deletion
  • Confusing billing management with storage permissions
  • Thinking role applies to bucket creation
4. You wrote this IAM policy but users report they cannot access the resource:
{
  "bindings": [
    {
      "role": "roles/editor",
      "members": ["user:bob@example.com"]
    }
  ]
}

What is the likely problem?
medium
A. The role "roles/editor" does not exist
B. The policy is missing the resource it applies to
C. The member email is incorrectly formatted
D. IAM policies cannot assign roles to users

Solution

  1. Step 1: Check the policy structure

    The policy snippet shows bindings but does not specify the resource it applies to.
  2. Step 2: Understand IAM policy application

    IAM policies must be attached to a specific resource (project, folder, or organization) to take effect.
  3. Final Answer:

    The policy is missing the resource it applies to -> Option B
  4. Quick Check:

    IAM policy needs resource context [OK]
Hint: IAM policies must be attached to resources to work [OK]
Common Mistakes:
  • Assuming roles can be assigned without resource context
  • Thinking role names are invalid
  • Believing member emails are wrongly formatted
5. You want to give a team member permission to manage Compute Engine instances but not billing or project settings. Which IAM role should you assign?
hard
A. roles/compute.instanceAdmin
B. roles/owner
C. roles/billing.admin
D. roles/viewer

Solution

  1. Step 1: Identify required permissions

    The team member needs to manage Compute Engine instances only, without billing or project-wide control.
  2. Step 2: Match role to permissions

    roles/compute.instanceAdmin allows managing instances but not billing or project settings, unlike roles/owner or billing.admin.
  3. Final Answer:

    roles/compute.instanceAdmin -> Option A
  4. Quick Check:

    Instance admin role limits permissions correctly [OK]
Hint: Use specific roles, not owner or billing, for limited access [OK]
Common Mistakes:
  • Assigning owner role gives too many permissions
  • Using billing.admin grants billing rights unnecessarily
  • Choosing viewer role does not allow managing instances