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
Access control (IAM vs ACLs) in GCP
📖 Scenario: You are managing access to a Google Cloud Storage bucket for a small team. You want to control who can read and write files in the bucket using two common methods: IAM roles and ACLs.
🎯 Goal: Build a simple configuration that sets up a Cloud Storage bucket with specific IAM roles and ACLs to control access for users.
📋 What You'll Learn
Create a Cloud Storage bucket named exactly team-data-bucket
Assign the IAM role roles/storage.objectViewer to the user user:alice@example.com
Assign the IAM role roles/storage.objectAdmin to the user user:bob@example.com
Set an ACL on the bucket to give user:charlie@example.com read access
Set an ACL on the bucket to give user:dana@example.com write access
💡 Why This Matters
🌍 Real World
Managing access to cloud storage is essential for protecting data and ensuring only authorized users can read or modify files.
💼 Career
Cloud engineers and administrators regularly configure IAM and ACLs to enforce security policies and compliance in cloud environments.
Progress0 / 4 steps
1
Create the Cloud Storage bucket
Create a Cloud Storage bucket named team-data-bucket using the resource block with google_storage_bucket.
GCP
Hint
Use the google_storage_bucket resource and set the name attribute exactly to team-data-bucket.
2
Add IAM roles for Alice and Bob
Add two google_storage_bucket_iam_member resources to assign the IAM role roles/storage.objectViewer to user:alice@example.com and the IAM role roles/storage.objectAdmin to user:bob@example.com for the bucket team-data-bucket.
GCP
Hint
Use two google_storage_bucket_iam_member resources with the bucket attribute set to the bucket name, and assign the correct role and member.
3
Add ACLs for Charlie and Dana
Add two google_storage_bucket_acl entries to give user:charlie@example.com read access and user:dana@example.com write access to the bucket team-data-bucket. Use the google_storage_bucket_acl resource with bucket set to the bucket name and specify the entity and role accordingly.
GCP
Hint
Use google_storage_bucket_acl resources with role set to READER or WRITER and entity set to user-email format with a dash.
4
Complete the configuration with bucket location
Add the location attribute with value US to the google_storage_bucket resource team_data_bucket to specify the bucket's geographic location.
GCP
Hint
Add the location attribute inside the bucket resource block and set it to US.
Practice
(1/5)
1. What is the main difference between IAM and ACLs in Google Cloud Platform?
easy
A. IAM and ACLs are exactly the same in functionality.
B. IAM controls network traffic, and ACLs control user passwords.
C. IAM is only for virtual machines, ACLs are for storage only.
D. IAM manages access at resource levels using roles, while ACLs manage access at object or bucket levels.
Solution
Step 1: Understand IAM scope
IAM controls access broadly by assigning roles to users or groups at resource levels like projects or services.
Step 2: Understand ACL scope
ACLs control access more narrowly, typically at the object or bucket level in storage services.
Final Answer:
IAM manages access at resource levels using roles, while ACLs manage access at object or bucket levels. -> Option D
Quick Check:
IAM = broad roles, ACLs = fine-grained object permissions [OK]
Hint: IAM is broad roles; ACLs are fine-grained permissions [OK]
Common Mistakes:
Confusing IAM with network controls
Thinking ACLs control passwords
Assuming IAM and ACLs are identical
2. Which of the following is the correct way to grant a user the role of 'Storage Object Viewer' using IAM in GCP?
easy
A. Edit the user's password in the IAM console.
B. Add the user to the ACL of the bucket with read permission.
C. Use the command: gcloud projects add-iam-policy-binding my-project --member='user:email@example.com' --role='roles/storage.objectViewer'
D. Create a firewall rule allowing the user access.
Solution
Step 1: Identify IAM command syntax
The correct gcloud command to grant IAM roles uses 'add-iam-policy-binding' with member and role flags.
Step 2: Verify role and member format
The role 'roles/storage.objectViewer' and member format 'user:email@example.com' are correct for granting read access to storage objects.
Final Answer:
Use the command: gcloud projects add-iam-policy-binding my-project --member='user:email@example.com' --role='roles/storage.objectViewer' -> Option C
Quick Check:
IAM role grant uses gcloud add-iam-policy-binding [OK]
Hint: Use gcloud add-iam-policy-binding with correct role and member [OK]
Common Mistakes:
Confusing ACL changes with IAM commands
Editing passwords instead of roles
Using firewall rules for access control
3. Given the following IAM policy snippet for a bucket, what access does the user 'user:alice@example.com' have?
B. Alice can create, delete, and update objects in the bucket.
C. Alice has no access to the bucket.
D. Alice can manage IAM policies but not objects.
Solution
Step 1: Identify the role assigned
The role 'roles/storage.objectAdmin' allows full control over objects in the bucket, including create, delete, and update.
Step 2: Confirm member access
The member 'user:alice@example.com' is assigned this role, so Alice has these permissions.
Final Answer:
Alice can create, delete, and update objects in the bucket. -> Option B
Quick Check:
roles/storage.objectAdmin = full object control [OK]
Hint: objectAdmin role means full object permissions [OK]
Common Mistakes:
Confusing objectAdmin with read-only roles
Assuming no access without explicit bucket ACL
Mixing IAM roles with IAM policy management
4. You tried to grant a user access to a Cloud Storage bucket by adding them to the bucket's ACL, but they still cannot access the objects. What is the likely issue?
medium
A. The bucket has uniform bucket-level access enabled, which disables ACLs.
B. The user needs to restart their computer.
C. The user's email address was misspelled in the ACL.
D. The user was not granted an IAM role at the project level.
Solution
Step 1: Understand uniform bucket-level access
When uniform bucket-level access is enabled, ACLs are disabled and only IAM controls access.
Step 2: Check ACL effect
Adding users to ACLs has no effect if uniform bucket-level access is on, so the user cannot access objects despite ACL changes.
Final Answer:
The bucket has uniform bucket-level access enabled, which disables ACLs. -> Option A
Assuming ACLs always work regardless of bucket settings
Blaming user typos without verification
Thinking user restart affects cloud permissions
5. You want to allow a third-party service to read specific objects in your Cloud Storage bucket without giving it full project access. Which approach is best?
hard
A. Add the service account to the bucket's ACL with READER permission on specific objects.
B. Enable uniform bucket-level access and grant the service account the storage.admin role.
C. Grant the service an IAM role at the project level with storage.objectViewer permission.
D. Create a firewall rule to allow the service IP to access the bucket.
Solution
Step 1: Understand access scope needs
The third-party service needs access only to specific objects, not the whole project.
Step 2: Choose fine-grained control method
ACLs allow granting permissions on specific objects or buckets, ideal for limited access.
Step 3: Evaluate other options
IAM roles at project level are too broad; storage.admin is too powerful; firewall rules do not control storage access.
Final Answer:
Add the service account to the bucket's ACL with READER permission on specific objects. -> Option A
Quick Check:
Use ACLs for fine-grained object access [OK]
Hint: Use ACLs for specific object access, IAM for broad access [OK]