0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AWS:強制的にMFAを設定させる方法

Posted at

強制的にMFAを設定させるためのIAMポリシー

IAMユーザーに以下のポリシーを付与することで、強制的にMFAの設定をさせることができます。
もし、MFA認証をせずにログインした場合、MFA以外の全AWSリソースへアクセスできないためです。

{
  "Version": "2012-10-17",
  "Statement": [
      {
          "Effect": "Allow",
          "Action": [
              "iam:ChangePassword"
          ],
          "Resource": [
              "arn:aws:iam::*:user/${aws:username}"
          ]
      },
      {
          "Effect": "Allow",
          "Action": [
              "iam:GetAccountPasswordPolicy"
          ],
          "Resource": "*"
      },
      {
          "Sid": "AllowIndividualUserToManageTheirOwnMFA",
          "Effect": "Allow",
          "Action": [
              "iam:CreateVirtualMFADevice",
              "iam:DeleteVirtualMFADevice",
              "iam:DeactivateMFADevice",
              "iam:EnableMFADevice",
              "iam:ResyncMFADevice",
              "iam:ListMFADevices"
          ],
          "Resource": [
              "arn:aws:iam::*:mfa/${aws:username}",
              "arn:aws:iam::*:user/${aws:username}"
          ]
      },
      {
          "Sid": "BlockMostAccessUnlessSignedInWithMFA",
          "Effect": "Deny",
          "NotAction": [
              "iam:CreateVirtualMFADevice",
              "iam:DeleteVirtualMFADevice",
              "iam:DeactivateMFADevice",
              "iam:EnableMFADevice",
              "iam:ResyncMFADevice",
              "iam:ListMFADevices",
              "iam:ChangePassword",
              "iam:GetAccountPasswordPolicy",
              "iam:ListVirtualMFADevices"
          ],
          "Resource": "*",
          "Condition": {
              "BoolIfExists": {
                  "aws:MultiFactorAuthPresent": "false"
              }
          }
      }
  ]
}

注意点

  • MFAの設定は添付画像の「セキュリティ認証情報」をクリックしてください。
    スクリーンショット 2023-12-05 14.15.36.png

  • MFA設定時のデバイス名は、IAMユーザーの名前と同じ名前にしてください。
    スクリーンショット 2023-12-05 14.13.15.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?