为什么在IAM策略中将条件应用于ec2:DescribeInstances失败? [英] Why does applying a condition to ec2:DescribeInstances in an IAM policy fail?

查看:129
本文介绍了为什么在IAM策略中将条件应用于ec2:DescribeInstances失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试配置可以使用策略列出的实例时,我注意到以下问题:

When trying to configure which instances can be listed using policies, I remark the following issue:


  • 如果条件未实现,所有实例都是可见的。

  • 实施任何条件时,都不可见。

带有条件的示例策略为包括:

The example policy with condition is included:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1461235889000",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances"
            ],
            "Resource": [
                "*"
            ],
            "Condition": {
                "StringEquals": {
                    "ec2:InstanceType": "r3.xlarge"
                }
            }
        }
    ]
}

这里出什么问题了?

推荐答案

ec2:DescribeInstances 操作否n支持资源级权限或应用条件。

来自上面的链接文档:


...使用这些操作在IAM策略中,必须通过对语句中Resource元素使用*通配符来授予用户使用该操作的所有资源的权限。 您不能将Amazon EC2条件键用于这些操作。

因此,您使用*通配符时不使用条件有效,但应用任何条件(截至撰写本文时)都将无法按预期工作。

So your usage of the * wildcard without a condition is valid, but applying any condition (as of this writing) will unfortunately not work as expected.

进一步阅读:

  • Supported Resource-Level Permissions for Amazon EC2 API Actions

这篇关于为什么在IAM策略中将条件应用于ec2:DescribeInstances失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆