Bird
Raised Fist0
GCPcloud~10 mins

Why advanced IAM matters in GCP - Test Your Understanding

Choose your learning style10 modes available
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.objectAdmin
Broles/owner
Croles/editor
Droles/viewer
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning overly broad roles like owner or editor unnecessarily.
2fill in blank
medium

Complete the code to create a custom IAM role with specific permissions.

GCP
gcloud iam roles create customRole --project=my-project --permissions=[1] --title='Custom Role'
Drag options to blanks, or click blank then click option'
Acompute.instances.start,compute.instances.stop
Bstorage.buckets.delete,storage.objects.create
Cstorage.buckets.get,storage.objects.list
Diam.roles.create,iam.roles.delete
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing permissions that allow deleting or creating resources when only read access is needed.
3fill in blank
hard

Fix the error in the IAM policy binding command to grant a service account the correct role.

GCP
gcloud projects add-iam-policy-binding my-project --member=[1] --role='roles/storage.objectViewer'
Drag options to blanks, or click blank then click option'
AserviceAccount:my-service-account@my-project.iam.gserviceaccount.com
Buser:my-service-account@my-project.iam.gserviceaccount.com
Cgroup:my-service-account@my-project.iam.gserviceaccount.com
Ddomain:my-service-account@my-project.iam.gserviceaccount.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user:' prefix for service accounts.
4fill in blank
hard

Fill both blanks to create a conditional IAM binding that grants access only if the request comes from a specific IP range.

GCP
gcloud projects add-iam-policy-binding my-project --member=[1] --role='roles/storage.objectViewer' --condition='expression=[2],title=IPRestriction'
Drag options to blanks, or click blank then click option'
Auser:alice@example.com
BipInCidr(request.sourceIp, '192.168.1.0/24')
Crequest.time < timestamp('2025-01-01T00:00:00Z')
Duser:bob@example.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong member types or incorrect condition expressions.
5fill in blank
hard

Fill all three blanks to define a least privilege IAM policy binding with a condition on device security status.

GCP
gcloud projects add-iam-policy-binding my-project --member=[1] --role=[2] --condition='expression=[3],title=DeviceSecurityCheck'
Drag options to blanks, or click blank then click option'
Auser:carol@example.com
Broles/iam.securityReviewer
Cdevice.trustedPlatformModulePresent == true
Droles/editor
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning broad roles like editor or missing the condition expression.

Practice

(1/5)
1. What is the main purpose of advanced IAM in Google Cloud?
easy
A. To speed up cloud resource deployment
B. To reduce cloud storage costs automatically
C. To control who can access and modify cloud resources
D. To monitor network traffic in real-time

Solution

  1. Step 1: Understand IAM's role in access control

    IAM (Identity and Access Management) is designed to manage who can do what with cloud resources.
  2. Step 2: Identify the main goal of advanced IAM

    Advanced IAM focuses on precise control of permissions to protect resources and data.
  3. Final Answer:

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

    Advanced IAM = Access control [OK]
Hint: Think: IAM means managing who can do what [OK]
Common Mistakes:
  • Confusing IAM with cost management
  • Thinking IAM speeds up deployment
  • Mixing IAM with network monitoring
2. Which of the following is the correct way to assign a role to a user in GCP IAM policy JSON?
easy
A. "members": "roles/viewer", "role": ["user:alice@example.com"]
B. "role": "user:alice@example.com", "members": ["roles/viewer"]
C. "user": "roles/viewer", "member": "alice@example.com"
D. "members": ["user:alice@example.com"], "role": "roles/viewer"

Solution

  1. Step 1: Recall correct IAM JSON structure

    IAM bindings use "role" for the role name and "members" as a list of identities.
  2. Step 2: Match correct syntax

    "members": ["user:alice@example.com"], "role": "roles/viewer" correctly places the user in "members" and the role in "role" with proper formatting.
  3. Final Answer:

    "members": ["user:alice@example.com"], "role": "roles/viewer" -> Option D
  4. Quick Check:

    Role = roles/viewer, Members = user list [OK]
Hint: Remember: role is a string, members is a list [OK]
Common Mistakes:
  • Swapping role and members fields
  • Using string instead of list for members
  • Incorrect key names like 'user' or 'member'
3. Given this IAM policy snippet:
{"bindings": [{"role": "roles/editor", "members": ["user:bob@example.com"]}]}

What access does Bob have?
medium
A. Edit access to most resources but not billing
B. Full control including billing management
C. Read-only access to all resources
D. No access until granted explicitly

Solution

  1. Step 1: Understand the role 'roles/editor'

    The 'editor' role allows editing most resources but excludes billing and owner-level permissions.
  2. Step 2: Match Bob's access

    Bob is assigned 'roles/editor', so he can edit resources but cannot manage billing or ownership.
  3. Final Answer:

    Edit access to most resources but not billing -> Option A
  4. Quick Check:

    roles/editor = edit access without billing [OK]
Hint: Editor role means edit, not full control [OK]
Common Mistakes:
  • Confusing editor with viewer role
  • Assuming editor includes billing rights
  • Thinking editor means no access
4. You wrote this IAM policy JSON but it fails to apply:
{"bindings": [{"role": "roles/viewer", "members": "user:carol@example.com"}]}

What is the error?
medium
A. The 'role' field is misspelled
B. The 'members' field should be a list, not a string
C. The user email format is incorrect
D. The JSON is missing a closing bracket

Solution

  1. Step 1: Check 'members' field type

    IAM policy requires 'members' to be a list of strings, not a single string.
  2. Step 2: Identify the error in the JSON snippet

    Here, 'members' is given as a string instead of a list, causing the failure.
  3. Final Answer:

    The 'members' field should be a list, not a string -> Option B
  4. Quick Check:

    Members must be list [OK]
Hint: Members always need brackets [] in JSON [OK]
Common Mistakes:
  • Using string instead of list for members
  • Ignoring JSON syntax rules
  • Assuming user email format is wrong
5. You want to give a team member access to only start and stop virtual machines but not delete or create them. Which IAM approach is best?
hard
A. Create a custom role with only 'start' and 'stop' permissions
B. Give the 'roles/editor' role for full editing rights
C. Assign the 'roles/viewer' role and let them request changes
D. Assign the predefined 'roles/compute.instanceAdmin' role

Solution

  1. Step 1: Understand predefined roles limits

    'roles/compute.instanceAdmin' and 'roles/editor' provide broad permissions including create and delete, which is too much.
  2. Step 2: Use custom role for precise permissions

    Creating a custom role with only 'start' and 'stop' VM permissions limits access exactly as needed.
  3. Final Answer:

    Create a custom role with only 'start' and 'stop' permissions -> Option A
  4. Quick Check:

    Custom role = precise access control [OK]
Hint: Use custom roles for exact permission needs [OK]
Common Mistakes:
  • Using broad predefined roles without restriction
  • Assuming viewer role allows start/stop
  • Giving editor role grants too many rights
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard