amazon-web-services - AWS IAM SSM - 限制实例可以运行的文档

标签 amazon-web-services amazon-ec2

有没有办法限制 EC2 实例 s.t. 的 IAM 策略?它只能运行一个简短的文档列表-我尝试像这样限制对 ssm:GetDocument 的访问:

{
  "Version": "2012-10-17",
  "Statement": [
    {
        "Effect": "Allow",
        "Action": [
            "ssm:GetDocument"
        ],
        "Resource": [
            "arn:aws:ssm:ap-southeast-2:*:document/MyCommand"
        ]
    }
 ]}

但是我可以在仍然包括 AWS-RunPowershellScript 文档的实例上运行任何命令。

此链接显示如何限制用户使用 ssm:sendCommand:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/delegate-commands.html

最佳答案

我还没有找到根据文档限制 SendCommand 的方法。如果用户没有访问权限,您会收到如下错误:

User: arn:aws:iam::123456789012:user/username is not authorized to perform: ssm:SendCommand on resource: arn:aws:ec2:us-east-1:123456789012:instance/i-01234567890abcdef



这表明 SendCommand 中的 Resource 可以根据实例 id 进行限制。如果其中一个条件是文档 ARN,那就太好了,但到目前为止我还没有找到任何方法来做到这一点(这不是策略生成器向导中的条件)。

更新:我在 AWS 论坛上发布了这个问题,希望能得到回复:https://forums.aws.amazon.com/thread.jspa?threadID=249039

更新 2:我收到了回复,解决方案是,要完成此操作,您必须使用 Resource 来指定允许在哪些实例上运行命令以及允许用户运行哪些文档。例如,这就是我最终得到的:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ssm:SendCommand"
            ],
            "Resource": [
                "arn:aws:ec2:*:123456789012:instance/*",
                "arn:aws:ssm:*:123456789012:document/RestartServices"
            ]
        }
    ]
}

关于amazon-web-services - AWS IAM SSM - 限制实例可以运行的文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37968885/

相关文章:

postgresql - 重启aws ec2实例后如何重启postgres数据库?

amazon-web-services - 如何重启Cassandra EC2实例?

amazon-web-services - AWS Cognito AdminLinkProviderForUser-用户池帐户和Facebook

amazon-web-services - 如何在 AWS API Gateway 中将对象转换为 JSON?

javascript - AWS 认知 : Can't get Credentials

ubuntu - 无法在 AWS EC2 Ubuntu 14.04 上运行 confluence

mercurial - Amazon EC2 上实际上是否有任何 Mercurial 托管?

security - AWS 云是否提供限制账单金额的选项?

amazon-web-services - 在 Cloudformation-YAML 中的单个资源中添加不同的参数值

amazon-web-services - 如果从同一实例转发,则 Amazon Web Services 负载均衡器转发到监听器不起作用