Conditions
Conditions provide fine-grained control over when IAM policies apply. They allow you to specify additional constraints that must be met for a policy statement to take effect, such as time-based access, IP restrictions, or resource-specific attributes.Condition Structure
Conditions are specified in theCondition element of a policy statement:
Condition Operators
String Conditions
Equals
Exact string match (case-sensitive).NotEquals
String does not match (case-sensitive).StringLike
Pattern matching with wildcards (* and ?).
StringNotLike
Pattern does not match.Numeric Conditions
NumericEquals
Exact numeric match.NumericLessThan
Numeric value is less than specified.NumericGreaterThan
Numeric value is greater than specified.Date/Time Conditions
DateEquals
Exact date/time match.DateGreaterThan
Current time is after specified date.DateLessThan
Current time is before specified date.Boolean Conditions
Bool
Boolean value match.IP Address Conditions
IpAddress
Request originates from specified IP range.NotIpAddress
Request does not originate from specified IP range.Condition Keys
Global Condition Keys
These keys are available in all contexts:aws:CurrentTime
Current date and time of the request.aws:SourceIp
IP address of the request source.aws:UserAgent
User agent string of the request.aws:MultiFactorAuthPresent
Whether multi-factor authentication was used.Service-Specific Condition Keys
Session Namespace (session:)
session:proctorAccountSid
Proctor account assigned to the session.session:schedulingModule
Scheduling system used for the session.session:status
Current status of the session.session:examType
Type of exam being proctored.User Namespace (user:)
user:role
User’s role in the system.user:department
User’s department affiliation.user:accountType
Type of user account.Assessment Namespace (assessment:)
assessment:type
Type of assessment.assessment:status
Current status of the assessment.Multiple Conditions
AND Logic (Multiple Operators)
All conditions must be true.OR Logic (Multiple Values)
Any value can match.Complex Logic
Combining AND and OR logic.Common Use Cases
Time-Based Access
Business Hours Only
Exam Period Access
Location-Based Access
Campus Network Only
Block Specific Locations
Role-Based Conditions
Department-Specific Access
Instructor-Only Features
Session-Specific Conditions
Assigned Proctor Only
Specific Scheduling Systems
Security Conditions
MFA Required for Sensitive Actions
Trusted User Agents Only
Advanced Patterns
Conditional Deny
Deny access unless conditions are met.Time-Window Access
Allow access only during specific time windows.Dynamic Resource Access
Access based on resource attributes.Best Practices
1. Use Specific Conditions
2. Combine Multiple Conditions
3. Use Deny for Security
4. Test Conditions Thoroughly
Always test conditions in a development environment before deploying to production.Troubleshooting
Common Issues
- Case Sensitivity: String conditions are case-sensitive
- Date Formats: Use ISO 8601 format for dates
- IP Ranges: Use CIDR notation for IP addresses
- Multiple Values: Use arrays for OR logic
- Variable Substitution: Ensure variables are properly formatted
Debugging Tips
- Log Condition Evaluations: Enable detailed logging
- Test Individual Conditions: Test each condition separately
- Validate Syntax: Use JSON validators for policy syntax
- Check Variable Values: Verify variable substitution works correctly
