【问题标题】:How do I allow Creating Tags only for certain operations - AWS IAM如何允许仅为特定操作创建标签 - AWS IAM
【发布时间】:2022-11-26 12:01:55
【问题描述】:

按照互联网上的 RunInstance 和 ec2:CreateTag + ec2:CreateAction 的示例,我试图只允许以下操作,如果在他们的创作设置了某个标签(此输出中不存在)。
如果我尝试一些测试,那么当我尝试创建带有标签的安全组时,我总是会收到错误消息。
我试图找到 ec2:CreateAction 文档并查看它期望的参数,但遗憾的是,我在 AWS 官方文档中的每一次搜索几乎没有显示任何内容。

有谁知道我可能做错了什么?

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "ec2:CreateTags",
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "ec2:CreateAction": [
                        "RunInstances",
                        "CreateRouteTable",
                        "CreateKeyPair",
                        "CreateRoute",
                        "CreateVolume",
                        "CreateNetworkInterface",
                        "CreateSecurityGroup",
                        "CreateSnapshot",
                        "CreateVpcPeeringConnection",
                        "CreateSubnet",
                        "CreateVPC",
                        "AllocateAddress"
                    ]
                }
            }
        }
    ]
}

【问题讨论】:

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


    【解决方案1】:

    必须创建三个规则,还需要设置 VPC 权限

    {
        "Effect": "Allow",
        "Action": "ec2:CreateSecurityGroup",
        "Resource": "arn:aws:ec2:*:0123456789:vpc/*"
    },
    {
        "Effect": "Allow",
        "Action": [
            "ec2:CreateSecurityGroup"
        ],
        "Resource": "arn:aws:ec2:*:0123456789:security-group/*",
        "Condition": {
            "StringEquals": {
                "aws:RequestTag/tagkey": "tagvalue"
            },
            "ForAnyValue:StringEquals": {
                "aws:TagKeys": [
                    "tagkey"
                ]
            }               
        }
    },
    {
        "Effect": "Allow",
        "Action": [
            "ec2:CreateTags"
        ],
        "Resource": "arn:aws:ec2:*:0123456789:security-group/*",
        "Condition": {
            "StringEquals": {
                "ec2:CreateAction" : "CreateSecurityGroup"
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多