tagging:要求创建/运行某类资源时必须打了标签

如果请求不包含指定的标签,以下 SCP 将阻止受影响账户中的 IAM 用户和角色创建特定资源类型。

"Sid": "DenyCreateSecretWithNoTag",是如果没有标签则拒绝创建secrets;

替换<tag-key>为你要求必须添加的标签键。

"Sid": "DenyRunInstanceWithNoTag",是如果没有标签则拒绝运行EC2实例。

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyCreateSecretWithNoTag",
      "Effect": "Deny",
      "Action": "secretsmanager:CreateSecret",
      "Resource": "*",
      "Condition": {
        "Null": {
          "aws:RequestTag/<tag-key>": "true"
        }
      }
    },
    {
      "Sid": "DenyRunInstanceWithNoTag",
      "Effect": "Deny",
      "Action": "ec2:RunInstances",
      "Resource": [
        "arn:aws:ec2:*:*:instance/*",
        "arn:aws:ec2:*:*:volume/*"
      ],
      "Condition": {
        "Null": {
          "aws:RequestTag/<tag-key>": "true"
        }
      }
    }
  ]
}

最后更新于