AWS IAM Show only untagged EC2 instances

一曲冷凌霜 提交于 2019-12-02 08:38:04

The use case to control which EC2 resources in same region IAM users can see based on tag (by other means) is not possible since all EC2 describe API calls do not support resource level permission.

Hence we cannot use EC2 conditions (except ec2:Region) with "ec2:Describe*" action. So, either you give permission to see resources or don't.

I think that when you have multiple conditions on a single IAM statement, they are handled in an AND situation, meaning that both must be true.

Try using 2 statements, each with a single condition:

{
"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"
            }
        }
    }
]}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!