Courseiva

Predict IAM decisions with an MFA condition

about 5 minutes

An administrator's policy allows full EC2 access but blocks terminating instances unless the session used MFA. Decide each request (the MFA key is present in every request's context).

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Ec2Admin",
      "Effect": "Allow",
      "Action": "ec2:*",
      "Resource": "*"
    },
    {
      "Sid": "TerminateNeedsMfa",
      "Effect": "Deny",
      "Action": "ec2:TerminateInstances",
      "Resource": "*",
      "Condition": {
        "Bool": {
          "aws:MultiFactorAuthPresent": "false"
        }
      }
    }
  ]
}
  • StopInstances without MFAMFA: no · source 198.51.100.7
  • TerminateInstances without MFAMFA: no · source 198.51.100.7
  • TerminateInstances with MFAMFA: yes · source 198.51.100.7
  • s3:ListAllMyBuckets with MFAMFA: yes · source 198.51.100.7