You're viewing OCI IAM documentation for new tenancies in regions that have been updated to use identity domains.

Restricting Access to Resources Based on Time Frame

You can use time-based variables in your policies to restrict the access granted in the policy to only certain time frames.

This feature allows you to restrict actions on resources to particular times. For example, you can create a policy that allows access only through a specified date. A policy like this would be useful if your company hires contractors and you want to ensure access is not allowed past the contract end date. Or, you could allow access to resources only during business hours (for example, Monday-Friday 9:00 AM - 5:00 PM). This restriction can lower the risk of a bad actor making changes when they are more likely to go unnoticed.

The variables that you can use to scope access based on time are:

  • request.utc-timestamp
  • request.utc-timestamp.month-of-year
  • request.utc-timestamp.day-of-month
  • request.utc-timestamp.day-of-week
  • request.utc-timestamp.time-of-day

Usage for these variables is described in more detail in the following sections.

Information for Working with Time-Based Variables

You must specify the time the variables using ISO 8601 format: YYYY-MM-DDThh:mm:ssZ. Examples of this format are:

  • Date and time with seconds: '2020-04-01T15:00:00Z'
  • Data and time with minutes: '2020-04-01T05:00Z'
  • Date only: '2020-04-01Z'
  • Time only: '05:00:00'

Even though you can specify a time down to seconds, you should allow for a 5 minute time difference between the timestamp on the request and the time the request is evaluated by the IAM service. This time difference can be caused by several factors, therefore be aware of this potential discrepancy when you plan and implement your time-based policies.

The time that you specify is evaluated as Coordinated Universal Time (UTC). This means that you must calculate the correct UTC time for the time zone in which the policy is evaluated. For example, to specify 9:00 AM Pacific Standard Time for the value of a variable, you would enter '17:00:00'. If your locale participates in daylight savings, you'll need to update any policies that refer to a specific hour when the time change goes into effect.

Details for Each Time-Based Variable

Usage for each variable is described in the following sections:

Was this article helpful?