Created
March 18, 2020 12:56
-
-
Save royharoush/d9694931f6d9f22d620b3222398d47e7 to your computer and use it in GitHub Desktop.
IAM Policy that allows API Calls, but restricts all Console actions(including View) if the user doesn't have MFA enabled. the only thing the user can do is change his own password and assign MFA.
This file contains hidden or 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": "AllowManageOwnVirtualMFADevice1", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:CreateVirtualMFADevice", | |
"iam:DeleteVirtualMFADevice" | |
], | |
"Resource": "arn:aws:iam::*:mfa/${aws:username}" | |
}, | |
{ | |
"Sid": "AllowViewAccountInfo", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:GetAccountPasswordPolicy", | |
"iam:GetAccountSummary", | |
"iam:ListVirtualMFADevices", | |
"iam:CreateVirtualMFADevice", | |
"iam:EnableMFADevice" | |
], | |
"Resource": "*" | |
}, | |
{ | |
"Sid": "AllowManageOwnPasswords", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:ChangePassword", | |
"iam:GetUser" | |
], | |
"Resource": "arn:aws:iam::*:user/${aws:username}" | |
}, | |
{ | |
"Sid": "AllowManageOwnAccessKeys", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:CreateAccessKey", | |
"iam:DeleteAccessKey", | |
"iam:ListAccessKeys", | |
"iam:UpdateAccessKey" | |
], | |
"Resource": "arn:aws:iam::*:user/${aws:username}" | |
}, | |
{ | |
"Sid": "AllowManageOwnSigningCertificates", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:DeleteSigningCertificate", | |
"iam:ListSigningCertificates", | |
"iam:UpdateSigningCertificate", | |
"iam:UploadSigningCertificate" | |
], | |
"Resource": "arn:aws:iam::*:user/${aws:username}" | |
}, | |
{ | |
"Sid": "AllowManageOwnSSHPublicKeys", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:DeleteSSHPublicKey", | |
"iam:GetSSHPublicKey", | |
"iam:ListSSHPublicKeys", | |
"iam:UpdateSSHPublicKey", | |
"iam:UploadSSHPublicKey" | |
], | |
"Resource": "arn:aws:iam::*:user/${aws:username}" | |
}, | |
{ | |
"Sid": "AllowManageOwnGitCredentials", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:CreateServiceSpecificCredential", | |
"iam:DeleteServiceSpecificCredential", | |
"iam:ListServiceSpecificCredentials", | |
"iam:ResetServiceSpecificCredential", | |
"iam:UpdateServiceSpecificCredential" | |
], | |
"Resource": "arn:aws:iam::*:user/${aws:username}" | |
}, | |
{ | |
"Sid": "AllowManageOwnVirtualMFADevice", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:CreateVirtualMFADevice", | |
"iam:DeleteVirtualMFADevice" | |
], | |
"Resource": "arn:aws:iam::*:mfa/${aws:username}" | |
}, | |
{ | |
"Sid": "AllowManageOwnUserMFA", | |
"Effect": "Allow", | |
"Action": [ | |
"iam:DeactivateMFADevice", | |
"iam:EnableMFADevice", | |
"iam:ListMFADevices", | |
"iam:ResyncMFADevice", | |
"iam:CreateVirtualMFADevice", | |
"iam:EnableMFADevice" | |
], | |
"Resource": "arn:aws:iam::*:user/${aws:username}" | |
}, | |
{ | |
"Sid": "DenyAllExceptListedIfNoMFA", | |
"Effect": "Deny", | |
"NotAction": [ | |
"iam:GetUser", | |
"iam:ListMFADevices", | |
"iam:ListVirtualMFADevices", | |
"iam:ResyncMFADevice", | |
"sts:GetSessionToken", | |
"iam:CreateVirtualMFADevice", | |
"iam:EnableMFADevice", | |
"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