Created
September 7, 2018 14:44
-
-
Save drAlberT/b134f21d335f8a8e70d834ef81030dc1 to your computer and use it in GitHub Desktop.
AWS IAM :: Enforce MFA both on Console and CLI
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": "AllowAllUsersToListAccountAliases", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:ListAccountAliases" | |
], | |
"Resource": [ | |
"*" | |
] | |
}, | |
{ | |
"Sid": "AllowAllUsersToListTheAvailbleMFADevices", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:ListVirtualMFADevices" | |
], | |
"Resource": [ | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:mfa/*" | |
] | |
}, | |
{ | |
"Sid": "AllowAllUsersToListAccounts", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:GetAccountPasswordPolicy", | |
"iam:ListUsers" | |
], | |
"Resource": [ | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:user/*" | |
] | |
}, | |
{ | |
"Sid": "AllowAllUsersToGetRole", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:GetRole" | |
], | |
"Resource": [ | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:role/*" | |
] | |
}, | |
{ | |
"Sid": "AllowIndividualUserToSeeTheirAccountInformationAndCreateAccessKey", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:ChangePassword", | |
"iam:CreateLoginProfile", | |
"iam:DeleteLoginProfile", | |
"iam:GetAccountPasswordPolicy", | |
"iam:GetAccountSummary", | |
"iam:GetLoginProfile", | |
"iam:UpdateLoginProfile" | |
], | |
"Resource": [ | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:user/${aws:username}" | |
] | |
}, | |
{ | |
"Sid": "AllowIndividualUserToListTheirMFA", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:ListMFADevices" | |
], | |
"Resource": [ | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:mfa/${aws:username}", | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:user/${aws:username}" | |
] | |
}, | |
{ | |
"Sid": "AllowIndividualUserToManageTheirMFA", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:CreateVirtualMFADevice", | |
"iam:DeleteVirtualMFADevice", | |
"iam:EnableMFADevice", | |
"iam:ResyncMFADevice" | |
], | |
"Resource": [ | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:mfa/${aws:username}", | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:user/${aws:username}" | |
] | |
}, | |
{ | |
"Sid": "DenyEverythingExceptForBelowUnlessMFAd", | |
"Effect": "Deny", | |
"NotAction": [ | |
"iam:ChangePassword", | |
"iam:CreateAccessKey", | |
"iam:CreateLoginProfile", | |
"iam:CreateVirtualMFADevice", | |
"iam:DeleteLoginProfile", | |
"iam:DeleteVirtualMFADevice", | |
"iam:EnableMFADevice", | |
"iam:GetAccountPasswordPolicy", | |
"iam:GetAccountSummary", | |
"iam:GetLoginProfile", | |
"iam:GetRole", | |
"iam:ListAccessKeys", | |
"iam:ListAccountAliases", | |
"iam:ListMFADevices", | |
"iam:ListUsers", | |
"iam:ListVirtualMFADevices", | |
"iam:ResyncMFADevice", | |
"iam:UpdateLoginProfile" | |
], | |
"Resource": "*", | |
"Condition": { | |
"BoolIfExists": { | |
"aws:MultiFactorAuthPresent": "false" | |
} | |
} | |
}, | |
{ | |
"Sid": "AllowBelowWhenMFAd", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:GetUser", | |
"iam:DeactivateMFADevice" | |
], | |
"Resource": [ | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:mfa/${aws:username}", | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:user/${aws:username}" | |
], | |
"Condition": { | |
"BoolIfExists": { | |
"aws:MultiFactorAuthPresent": "true" | |
} | |
} | |
}, | |
{ | |
"Sid": "DenyIamAccessToOtherAccountsUnlessMFAd", | |
"Effect": "Deny", | |
"Action": [ | |
"iam:ChangePassword", | |
"iam:CreateAccessKey", | |
"iam:CreateLoginProfile", | |
"iam:CreateVirtualMFADevice", | |
"iam:DeactivateMFADevice", | |
"iam:DeleteLoginProfile", | |
"iam:DeleteVirtualMFADevice", | |
"iam:EnableMFADevice", | |
"iam:GetAccountPasswordPolicy", | |
"iam:GetLoginProfile", | |
"iam:ListAccessKeys", | |
"iam:ResyncMFADevice", | |
"iam:UpdateLoginProfile" | |
], | |
"NotResource": [ | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:mfa/${aws:username}", | |
"arn:aws:iam::XXX-REPLACE-WITH-ACCOUNT-ID-XXX:user/${aws:username}" | |
], | |
"Condition": { | |
"BoolIfExists": { | |
"aws:MultiFactorAuthPresent": "false" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment