Skip to content

Instantly share code, notes, and snippets.

@serban-petrescu
Last active May 29, 2021 10:51
Show Gist options
  • Save serban-petrescu/22c3bc3091a8b7c5edabc6dfe815054f to your computer and use it in GitHub Desktop.
Save serban-petrescu/22c3bc3091a8b7c5edabc6dfe815054f to your computer and use it in GitHub Desktop.
AWS MFA Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyAllExceptListedIfNoMFA",
"Effect": "Deny",
"NotAction": [
"iam:ChangePassword",
"iam:GetAccountPasswordPolicy",
"iam:CreateVirtualMFADevice",
"iam:EnableMFADevice",
"iam:GetUser",
"iam:ListMFADevices",
"iam:ListVirtualMFADevices",
"iam:ResyncMFADevice",
"sts:GetSessionToken"
],
"Resource": "*",
"Condition": {
"BoolIfExists": {
"aws:MultiFactorAuthPresent": "false"
}
}
}
]
}
aws sts get-session-token ^
--serial-number arn:aws:iam::<account>:mfa/<user> ^
--token-code <mfa token>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment