Skip to content

Instantly share code, notes, and snippets.

@mixja
Last active June 28, 2020 08:20
Show Gist options
  • Save mixja/15d2969efe806680c2a4b0059daaf697 to your computer and use it in GitHub Desktop.
Save mixja/15d2969efe806680c2a4b0059daaf697 to your computer and use it in GitHub Desktop.
AWS IAM Policy for MFA
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllUsersToListAccounts",
"Effect": "Allow",
"Action": [
"iam:ListAccountAliases",
"iam:GetAccountPasswordPolicy",
"iam:ListUsers",
"iam:GetAccountSummary"
],
"Resource": [
"*"
]
},
{
"Sid": "AllowIndividualUserToSeeTheirAccountInformationAndCreateAccessKey",
"Effect": "Allow",
"Action": [
"iam:ChangePassword",
"iam:CreateLoginProfile",
"iam:DeleteLoginProfile",
"iam:GetAccountPasswordPolicy",
"iam:GetLoginProfile",
"iam:UpdateLoginProfile",
"iam:CreateAccessKey",
"iam:ListAccessKeys"
],
"Resource": [
"arn:aws:iam::PASTE_ACCOUNT_NUMBER:user/${aws:username}"
]
},
{
"Sid": "AllowIndividualUserToListTheirMFA",
"Effect": "Allow",
"Action": [
"iam:ListVirtualMFADevices",
"iam:ListMFADevices"
],
"Resource": [
"arn:aws:iam::PASTE_ACCOUNT_NUMBER:mfa/*",
"arn:aws:iam::PASTE_ACCOUNT_NUMBER:user/${aws:username}"
]
},
{
"Sid": "AllowIndividualUserToManageTheirMFA",
"Effect": "Allow",
"Action": [
"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:ResyncMFADevice"
],
"Resource": [
"arn:aws:iam::PASTE_ACCOUNT_NUMBER:mfa/${aws:username}",
"arn:aws:iam::PASTE_ACCOUNT_NUMBER:user/${aws:username}"
]
},
{
"Sid": "DenyEverythingExceptForBelowUnlessMFAd",
"Effect": "Deny",
"NotAction": [
"iam:ListVirtualMFADevices",
"iam:ListMFADevices",
"iam:ListUsers",
"iam:ListAccountAliases",
"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:ResyncMFADevice",
"iam:ChangePassword",
"iam:CreateLoginProfile",
"iam:DeleteLoginProfile",
"iam:GetAccountPasswordPolicy",
"iam:GetAccountSummary",
"iam:GetLoginProfile",
"iam:UpdateLoginProfile"
],
"Resource": "*",
"Condition": {
"Null": {
"aws:MultiFactorAuthAge": "true"
}
}
},
{
"Sid": "DenyIamAccessToOtherAccountsUnlessMFAd",
"Effect": "Deny",
"Action": [
"iam:CreateVirtualMFADevice",
"iam:DeactivateMFADevice",
"iam:DeleteVirtualMFADevice",
"iam:EnableMFADevice",
"iam:ResyncMFADevice",
"iam:ChangePassword",
"iam:CreateLoginProfile",
"iam:DeleteLoginProfile",
"iam:GetAccountPasswordPolicy",
"iam:GetLoginProfile",
"iam:UpdateLoginProfile",
"iam:CreateAccessKey",
"iam:ListAccessKeys"
],
"NotResource": [
"arn:aws:iam::PASTE_ACCOUNT_NUMBER:mfa/${aws:username}",
"arn:aws:iam::PASTE_ACCOUNT_NUMBER:user/${aws:username}"
],
"Condition": {
"Null": {
"aws:MultiFactorAuthAge": "true"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment