-
-
Save ardeshir/c4a07960391e06fe7b019a7ddcb5701f to your computer and use it in GitHub Desktop.
Force Multi-Factor Authentication (MFA) on AWS IAM Accounts
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": "AllowAllUsersToListAccounts", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:ListAccountAliases", | |
"iam:ListUsers", | |
"iam:GetAccountSummary" | |
], | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "AllowIndividualUserToSeeAndManageTheirOwnAccountInformation", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:ChangePassword", | |
"iam:CreateAccessKey", | |
"iam:CreateLoginProfile", | |
"iam:DeleteAccessKey", | |
"iam:DeleteLoginProfile", | |
"iam:GetAccountPasswordPolicy", | |
"iam:GetLoginProfile", | |
"iam:ListAccessKeys", | |
"iam:UpdateAccessKey", | |
"iam:UpdateLoginProfile", | |
"iam:ListSigningCertificates", | |
"iam:DeleteSigningCertificate", | |
"iam:UpdateSigningCertificate", | |
"iam:UploadSigningCertificate", | |
"iam:ListSSHPublicKeys", | |
"iam:GetSSHPublicKey", | |
"iam:DeleteSSHPublicKey", | |
"iam:UpdateSSHPublicKey", | |
"iam:UploadSSHPublicKey" | |
], | |
"Resource": "arn:aws:iam::ACCOUNT_ID:user/${aws:username}" | |
}, | |
{ | |
"Sid": "AllowIndividualUserToListTheirOwnMFA", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:ListVirtualMFADevices", | |
"iam:ListMFADevices" | |
], | |
"Resource": [ | |
"arn:aws:iam::ACCOUNT_ID:mfa/*", | |
"arn:aws:iam::ACCOUNT_ID:user/${aws:username}" | |
] | |
}, | |
{ | |
"Sid": "AllowIndividualUserToManageTheirOwnMFA", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:CreateVirtualMFADevice", | |
"iam:DeactivateMFADevice", | |
"iam:DeleteVirtualMFADevice", | |
"iam:RequestSmsMfaRegistration", | |
"iam:FinalizeSmsMfaRegistration", | |
"iam:EnableMFADevice", | |
"iam:ResyncMFADevice" | |
], | |
"Resource": [ | |
"arn:aws:iam::ACCOUNT_ID:mfa/${aws:username}", | |
"arn:aws:iam::ACCOUNT_ID:user/${aws:username}" | |
] | |
}, | |
{ | |
"Sid": "BlockAnyAccessOtherThanAboveUnlessSignedInWithMFA", | |
"Effect": "Deny", | |
"NotAction": [ | |
"iam:ListAccountAliases", | |
"iam:ListUsers", | |
"iam:GetAccountSummary", | |
"iam:ChangePassword", | |
"iam:CreateAccessKey", | |
"iam:CreateLoginProfile", | |
"iam:DeleteAccessKey", | |
"iam:DeleteLoginProfile", | |
"iam:GetAccountPasswordPolicy", | |
"iam:GetLoginProfile", | |
"iam:ListAccessKeys", | |
"iam:UpdateAccessKey", | |
"iam:UpdateLoginProfile", | |
"iam:ListSigningCertificates", | |
"iam:DeleteSigningCertificate", | |
"iam:UpdateSigningCertificate", | |
"iam:UploadSigningCertificate", | |
"iam:ListSSHPublicKeys", | |
"iam:GetSSHPublicKey", | |
"iam:DeleteSSHPublicKey", | |
"iam:UpdateSSHPublicKey", | |
"iam:UploadSSHPublicKey", | |
"iam:ListVirtualMFADevices", | |
"iam:ListMFADevices", | |
"iam:CreateVirtualMFADevice", | |
"iam:DeactivateMFADevice", | |
"iam:DeleteVirtualMFADevice", | |
"iam:RequestSmsMfaRegistration", | |
"iam:FinalizeSmsMfaRegistration", | |
"iam:EnableMFADevice", | |
"iam:ResyncMFADevice" | |
], | |
"Resource": "*", | |
"Condition": { | |
"BoolIfExists": { | |
"aws:MultiFactorAuthPresent": "false" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment