how to create account following info in IAM policy.

0

Hello,

i'm trying to finish a lab, but got stuck at this one.

"create a policy called all-users which covers the following:

  1. Users can create/list all MFA devices (including virtual) and list MFA device tags.
  2. Users can only enable/deactivate their own MFA devices.
  3. Users can only delete their own virtual MFA device on the condition that they have enabled MFA.

You'll need to use Policy variables such as ${aws:username}."

now, trying to create this, but never able to figure out what exactly has to be done where I can't go to next step. could someone help figuring out what has to be done exactly?

Thank you

  • Why don't you post what you think should work, and what goes wrong? Then we can suggest adjustments.

已提问 1 年前264 查看次数
1 回答
1

You can create a custom IAM policy named "all-users" with the following JSON policy document to achieve the requirements:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "iam:ListMFADevices",
                "iam:ListVirtualMFADevices"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "iam:CreateVirtualMFADevice",
                "iam:EnableMFADevice",
                "iam:DeactivateMFADevice"
            ],
            "Resource": "arn:aws:iam::*:user/${aws:username}"
        },
        {
            "Effect": "Allow",
            "Action": "iam:DeleteVirtualMFADevice",
            "Resource": "arn:aws:iam::*:mfa/${aws:username}",
            "Condition": {
                "BoolIfExists": {
                    "aws:MultiFactorAuthPresent": "true"
                }
            }
        }
    ]
}

This policy will allow users to create and list MFA devices and tags, enable and deactivate their own MFA devices, and delete their own virtual MFA devices if MFA is enabled.

profile picture
专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则