限制 IAM ec2:CopySnapshot 对具有特定键值的快照的操作

问题描述 投票:0回答:1

我有一些 ec2 快照,其标签为键 ce 和值 ae-12 。我想允许角色对仅包含上述标签的快照执行 ec2:CopySnapshot 操作。 我正在使用以下策略,但它不起作用:

{
            "Sid": "snapshare",
            "Effect": "Allow",
            "Action": [
                "ec2:CopySnapshot"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "ec2:ResourceTag/ce": "ae-12"
                }
            }
        }

我还在条件块中尝试了 "aws:ResourceTag/ce": "yes" 但它也失败了。

任何人都可以帮助我如何通过 IAM 政策解决这个问题吗?

amazon-web-services amazon-ec2 snapshot
1个回答
0
投票

根据文档

CopySnapshot
可用的条件键有:

  • aws:RequestTag/${TagKey}

  • aws:TagKeys

  • ec2:OutpostArn

  • ec2:SnapshotID

所以你可以尝试:

{
    "Sid": "snapshare",
    "Effect": "Allow",
    "Action": [
        "ec2:CopySnapshot"
    ],
    "Resource": "*",
    "Condition": {
        "StringEquals": {
            "aws:RequestTag/ce": "ae-12"
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.