SCP - Require tag Project on every resource

0

Hello,

I'm looking into SCPs, and I see that's possible to require a tag for EC2 for example with the following policy:

{
      "Sid": "DenyRunInstanceWithNoProjectTag",
      "Effect": "Deny",
      "Action": "ec2:RunInstances",
      "Resource": [
        "arn:aws:ec2:*:*:instance/*",
        "arn:aws:ec2:*:*:volume/*"
      ],
      "Condition": {
        "Null": {
          "aws:RequestTag/Project": "true"
        }
      }
    }

But what in case when I want to create a policy which would deny creation or any modification of any resource when it doesn't have tag Project. Can I simply use wildcard for action and resource, like below?

{
      "Sid": "DenyResourcesWithNoProjectTag",
      "Effect": "Deny",
      "Action": "*",
      "Resource": "*",
      "Condition": {
        "Null": {
          "aws:RequestTag/Project": "true"
        }
      }
    }
已提问 4 个月前137 查看次数
1 回答
1

Hello.

If you set this, all resources that do not have tags set will become Deny, so some services will become inoperable.
For example, you may encounter problems such as not being able to select an AMI even if you want to start EC2.
Therefore, I think it is necessary to set the required action in "Action" and which resource to target in the "Resource" section.
https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html

profile picture
专家
已回答 4 个月前
  • If you set this, all resources that do not have tags set will become Deny, so some services will become inoperable.

    But that would only apply to resources which can be tagged, right? And may be inoperable until they are tagged with Project, right?

  • Yes, services that allow tagging may become unavailable.

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

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

回答问题的准则