Skip to content

Instantly share code, notes, and snippets.

@o6uoq
Last active March 27, 2025 11:15
Show Gist options
  • Save o6uoq/8b9f3f3f80b7e8857dbc8bec03e4c653 to your computer and use it in GitHub Desktop.
Save o6uoq/8b9f3f3f80b7e8857dbc8bec03e4c653 to your computer and use it in GitHub Desktop.
AWS: EnforceMFAOnLogin
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowLoginPasswordResetAndMFASetup",
"Effect": "Allow",
"Action": [
"iam:GetUser",
"iam:GetLoginProfile",
"iam:ChangePassword",
"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:ListMFADevices",
"iam:ListVirtualMFADevices",
"iam:ResyncMFADevice",
"iam:DeleteVirtualMFADevice"
],
"Resource": "arn:aws:iam::*:user/${aws:username}"
},
{
"Sid": "DenyAllExceptMFASetupIfNotUsingMFA",
"Effect": "Deny",
"NotAction": [
"iam:GetUser",
"iam:GetLoginProfile",
"iam:ChangePassword",
"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:ListMFADevices",
"iam:ListVirtualMFADevices",
"iam:ResyncMFADevice",
"iam:DeleteVirtualMFADevice"
],
"Resource": "*",
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "false"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment