Limit switch role by Time

Limit switch role by Time

  1. Access the IAM console page at the link https://console.aws.amazon.com/iam/home#/home with Admin user rights
  2. In the left navigation pane, select Roles, then select the newly created IAM Role lab44-RoleFullAccess
  3. In the Trust relationships tab, click Edit trust relationship, add Condition as shown below, then click Update Trust Policy
    "DateGreaterThan": {
        "aws:CurrentTime": "2026-07-16T00:00:00Z"
    },
    "DateLessThan": {
        "aws:CurrentTime": "2026-07-16T07:00:00Z"
    }

4.3_TimeCondition

  1. Return to the login session of the user No-permission-user, perform the switch role again, you will receive the error message as shown below because the time when you perform the Switch has been outside the allowed time range.

4.3_Error