【问题标题】:AWS IAM Show only untagged EC2 instancesAWS IAM 仅显示未标记的 EC2 实例
【发布时间】:2018-06-02 00:06:52
【问题描述】:

我正在尝试引入访客 IAM 策略来限制对 EC2 实例的访问。 我正在尝试实现这一点,访客政策仅显示未标记为“部门”或未标记为“部门 = 访客”的实例。

这是我为此制定的政策:

政策:

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "VisualEditor0",
        "Effect": "Allow",
        "Action": [
            "ec2:Describe*"
        ],
        "Resource": "*",
        "Condition": {
            "StringEquals": {
                "ec2:ResourceTag/Department": "Guest"
            },
            "Null": {
                "ec2:ResourceTag/Department": "true"
            }
        }
    }
]}

"Department = Guest" 比较运行良好,但资源标签存在检查不起作用。

有没有其他方法可以列出没有“部门”标签的实例?

【问题讨论】:

    标签: amazon-web-services amazon-ec2 amazon-iam


    【解决方案1】:

    由于所有 EC2 都描述了 API 调用do not support resource level permission,因此无法根据标签(通过其他方式)控制同一区域 IAM 用户可以查看哪些 EC2 资源的用例。

    因此,我们不能将 EC2 条件(ec2:Region 除外)与“ec2:Describe*”操作一起使用。因此,您要么授予查看资源的权限,要么不授予权限。

    【讨论】:

    • 你是对的!我没有注意到部门比较都不起作用。
    【解决方案2】:

    我认为,当您在单个 IAM 语句中有多个条件时,它们会在 AND 情况下处理,这意味着两者都必须为真。

    尝试使用 2 个语句,每个语句都有一个条件:

    {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "ec2:Describe*"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "ec2:ResourceTag/Department": "Guest"
                }
            }
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "ec2:Describe*"
            ],
            "Resource": "*",
            "Condition": {
                "Null": {
                    "ec2:ResourceTag/Department": "true"
                }
            }
        }
    ]}
    

    【讨论】:

      猜你喜欢
      • 2017-07-24
      • 2019-08-06
      • 2015-11-29
      • 2022-07-15
      • 2014-04-08
      • 2016-02-07
      • 2014-11-18
      • 2016-12-25
      • 1970-01-01
      相关资源
      最近更新 更多