0
0
GCPcloud~20 mins

IAM conditions for fine-grained control in GCP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
IAM Conditions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding IAM Condition Expressions
Which of the following IAM condition expressions correctly restricts access to a resource only during business hours (9 AM to 5 PM) in UTC?
Arequest.time >= timestamp('2024-01-01T09:00:00Z') && request.time <= timestamp('2024-01-01T17:00:00Z')
B71 < )(ruoHteg.emit.tseuqer && 9 => )(ruoHteg.emit.tseuqer
Crequest.time.getHour() >= 9 && request.time.getHour() < 17
Drequest.time >= timestamp('09:00:00Z') && request.time <= timestamp('17:00:00Z')
Attempts:
2 left
💡 Hint
IAM conditions support request.time.getHour() to extract the hour (0-23) for recurring daily restrictions.
Configuration
intermediate
2:00remaining
IAM Condition to Restrict Access by IP Address
Which IAM condition expression correctly restricts access to a resource only if the request comes from the IP range 192.168.1.0/24?
Arequest.ip == '192.168.1.0/24'
Brequest.ip in ip_cidr_range('192.168.1.0/24')
Crequest.ip in ['192.168.1.0/24']
Drequest.ip.startsWith('192.168.1.')
Attempts:
2 left
💡 Hint
Use the ip_cidr_range() function to check if an IP is within a CIDR range.
Architecture
advanced
2:00remaining
Designing IAM Conditions for Multi-Project Access
You want to grant a user access to a resource only if the request originates from a specific project (project-123) and the request is made during weekdays. Which IAM condition expression achieves this?
Aresource.project == 'project-123' && request.time.getDayOfWeek() >= 1 && request.time.getDayOfWeek() <= 5
Bresource.project == 'project-123' && request.time.getDayOfWeek() > 0 && request.time.getDayOfWeek() < 6
Cresource.project == 'project-123' && request.time.getDayOfWeek() > 1 && request.time.getDayOfWeek() < 5
Dresource.project == 'project-123' && request.time.getDayOfWeek() >= 1 && request.time.getDayOfWeek() < 6
Attempts:
2 left
💡 Hint
request.time.getDayOfWeek() returns 1 (Monday) to 7 (Sunday). Use resource.project or resource.name.startsWith('projects/project-123/').
security
advanced
2:00remaining
Preventing Privilege Escalation with IAM Conditions
Which IAM condition expression helps prevent privilege escalation by restricting role changes only to a specific group email domain?
Arequest.auth.email.endsWith('@example.com')
Brequest.auth.claims.email.contains('@example.com')
Crequest.auth.claims.email == '@example.com'
Drequest.auth.token_email.endsWith('@example.com')
Attempts:
2 left
💡 Hint
Use request.auth.token_email and endsWith() to validate the authenticated user's email domain.
service_behavior
expert
2:00remaining
Evaluating IAM Condition Impact on Service Behavior
Given this IAM condition on a Cloud Storage bucket:
request.time < timestamp('2024-12-31T23:59:59Z') && request.auth.token_email.endsWith('@partner.com')
What will happen if a user with email user@partner.com tries to access the bucket on 2025-01-01T00:00:00Z?
AAccess is denied because the request time is after the allowed timestamp.
BAccess is granted because the email domain matches, ignoring time.
CAccess is denied because the email domain does not match.
DAccess is granted because IAM conditions do not enforce time restrictions.
Attempts:
2 left
💡 Hint
IAM conditions with && require ALL parts to evaluate to true.