I want to follow best practices by limiting the ability of users to take certain actions and by restricting access to specific IP addresses of a physical office location or VPN connection. However, I also want to allow these users to use the Switch Role feature of the AWS Management Console.

The Switch Role feature in the AWS Management Console allows you to assume roles, both for your account and for cross-account access. Because the request to switch roles is issued from the IP address of the AWS Management Console—which is not one of the allowed source IP addresses—the feature is blocked by source IP restrictions in the user policy.

For example, consider the following user policy, which explicitly denies access to all actions and resources from any IP address that is not included in the SourceIp specification:

{

"Version": "2012-10-17",

"Statement": [

{

"Effect": "Deny",

"Action": "*",

"Resource": "*",

"Condition": {

"NotIpAddress": {

"aws:SourceIp": [

"123.123.123.123/24"

]

}

}

}

]

}

And the following AssumeRole policy, which allows a user to assume the role RoleA in the account 12345678901:

{

"Version": "2012-10-17",

"Statement": {

"Effect": "Allow",

"Action": "sts:AssumeRole",

"Resource": "arn:aws:iam::12345678901:role/RoleA"

}

}

The user cannot assume RoleA because the AssumeRole action would be initiated from an IP address external to the range specified in the SourceIp range of the user policy.