Limit switch role by IP

Limit Switch role by IP

  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 policy, add Condition as shown below, delete Service: ec2.amazonaws.com, then click Update Trust Policy
    "Condition": {
        "IpAddress": {
            "aws:SourceIp": "203.0.113.0/24"
        }
    }

4.3_IPCondition

  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 you are accessing the service from a device that does not have the IP like within the conditions.

4.3_Error