Created
July 7, 2023 14:34
-
-
Save viralsavaniIM/5a846d09264e286f2cc18b128714e1e5 to your computer and use it in GitHub Desktop.
IAM policy for closed scope on MFA policies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "AllowViewAccountInfo", | |
"Effect": "Allow", | |
"Action": "iam:ListVirtualMFADevices", | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "AllowManageOwnVirtualMFADevice", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:CreateVirtualMFADevice" | |
], | |
"Resource": "arn:aws:iam::*:mfa/*" | |
}, | |
{ | |
"Sid": "AllowManageOwnUserMFA", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:DeactivateMFADevice", | |
"iam:EnableMFADevice", | |
"iam:GetUser", | |
"iam:ListMFADevices", | |
"iam:ResyncMFADevice", | |
"iam:ChangePassword" | |
], | |
"Resource": "arn:aws:iam::*:user/${aws:username}" | |
}, | |
{ | |
"Sid": "DenyAllExceptListedIfNoMFA", | |
"Effect": "Deny", | |
"NotAction": [ | |
"iam:CreateVirtualMFADevice", | |
"iam:EnableMFADevice", | |
"iam:GetUser", | |
"iam:ListMFADevices", | |
"iam:ListVirtualMFADevices", | |
"iam:ResyncMFADevice", | |
"sts:GetSessionToken", | |
"iam:ChangePassword" | |
], | |
"Resource": "*", | |
"Condition": { | |
"BoolIfExists": { | |
"aws:MultiFactorAuthPresent": "false" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment