gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 20:18:33 31 4
gpt4 key购买 nike

有没有办法限制 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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com