0
0
GCPcloud~10 mins

Access control (IAM vs ACLs) in GCP - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to grant a user the role of Storage Object Viewer using IAM.

GCP
resource = "projects/my-project"
policy = client.get_iam_policy(resource)
policy.bindings.append({"role": "[1]", "members": ["user:alice@example.com"]})
client.set_iam_policy(resource, policy)
Drag options to blanks, or click blank then click option'
Aroles/editor
Broles/storage.admin
Croles/compute.viewer
Droles/storage.objectViewer
Attempts:
3 left
💡 Hint
Common Mistakes
Using admin role when only viewer is needed
Confusing compute roles with storage roles
2fill in blank
medium

Complete the code to set an ACL that grants read access to all users on a Cloud Storage bucket.

GCP
bucket = client.get_bucket('my-bucket')
bucket.acl.[1].all().grant_read()
bucket.acl.save()
Drag options to blanks, or click blank then click option'
Auser
Bgroup
Cpublic
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user' instead of 'public' for open access
Forgetting to save the ACL after changes
3fill in blank
hard

Fix the error in the IAM policy binding to correctly specify the member type for a service account.

GCP
policy.bindings.append({"role": "roles/storage.admin", "members": ["[1]:my-service-account@my-project.iam.gserviceaccount.com"]})
Drag options to blanks, or click blank then click option'
AserviceAccount
Buser
Cgroup
Ddomain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user' prefix for service accounts
Omitting the prefix entirely
4fill in blank
hard

Fill both blanks to create an IAM policy that grants a group the role of Compute Viewer on a project.

GCP
policy.bindings.append({"role": "[1]", "members": ["[2]:dev-team@example.com"]})
Drag options to blanks, or click blank then click option'
Aroles/compute.viewer
Broles/storage.admin
Cgroup
Duser
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user' instead of 'group' for group members
Choosing wrong roles like storage admin for compute tasks
5fill in blank
hard

Fill all three blanks to create an ACL entry that grants write access to a specific user on a bucket.

GCP
bucket.acl.[1].[2]().grant_[3]()
bucket.acl.save()
Drag options to blanks, or click blank then click option'
Auser
Ball
Cwrite
Dgroup
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'group' instead of 'user' for individual access
Using grant_read() instead of grant_write() for write access