Skip to content
IAM Policy Generator

IAM policy example: let users manage their own MFA device, with a least privilege rewrite

Allows an IAM user to create, enable, resync and delete a virtual MFA device and to list their own MFA devices, scoped to their own user name with the aws:username variable. It follows the AWS documentation example for self-managed MFA. The original uses a wildcard on every user.

Open the workbench ยท All examples

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ManageMfa",
      "Effect": "Allow",
      "Action": [
        "iam:*MFADevice",
        "iam:ListMFADevices",
        "iam:ListVirtualMFADevices"
      ],
      "Resource": "*"
    }
  ]
}

What it allows

  • Allows creating, enabling, deactivating, deleting and resyncing MFA devices for every user in the account.

What it allows

  1. Allow 10 actions (iam:*MFADevice, iam:ListMFADevices, iam:ListVirtualMFADevices) on every resource.

    Action or patternActionsAccess levels
    iam:*MFADevice8Read 1, Write 5, Tagging 2
    iam:ListMFADevices1List 1
    iam:ListVirtualMFADevices1List 1

Checks

The wildcard iam:*MFADevice covers 8 actions and the resource is every user, so one user can remove another user's MFA.

Least privilege rewrite

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListOwnMfa",
      "Effect": "Allow",
      "Action": [
        "iam:ListMFADevices",
        "iam:ListVirtualMFADevices"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ManageOwnMfa",
      "Effect": "Allow",
      "Action": [
        "iam:CreateVirtualMFADevice",
        "iam:EnableMFADevice",
        "iam:ResyncMFADevice",
        "iam:DeactivateMFADevice",
        "iam:DeleteVirtualMFADevice"
      ],
      "Resource": [
        "arn:aws:iam::111122223333:mfa/${aws:username}",
        "arn:aws:iam::111122223333:user/${aws:username}"
      ]
    }
  ]
}

The rewrite names five actions and scopes them to the caller's own user and MFA device ARN. Other users' devices cannot be changed.

What it allows

  1. Allow 2 actions (iam:ListMFADevices, iam:ListVirtualMFADevices) on every resource.

    Action or patternActionsAccess levels
    iam:ListMFADevices1List 1
    iam:ListVirtualMFADevices1List 1
  2. Allow 5 actions (iam:CreateVirtualMFADevice, iam:EnableMFADevice, iam:ResyncMFADevice, iam:DeactivateMFADevice, iam:DeleteVirtualMFADevice) on arn:aws:iam::111122223333:mfa/${aws:username}, arn:aws:iam::111122223333:user/${aws:username}.

    Action or patternActionsAccess levels
    iam:CreateVirtualMFADevice1Write 1
    iam:EnableMFADevice1Write 1
    iam:ResyncMFADevice1Write 1
    iam:DeactivateMFADevice1Write 1
    iam:DeleteVirtualMFADevice1Write 1

Checks

No flags from the six checks.

Sources

  1. IAM User Guide: self-manage an MFA device, read 16 Nov 2026
  2. IAM User Guide: require MFA for API access, read 16 Nov 2026
  3. AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026

Last reviewed 16 Nov 2026.