我试图授予IAM组编辑EC2安全组的权限,但是如果不授予对EC2中所有内容的访问权限,我一直无法使其工作。
我已经尝试了几个版本:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1392336685000", "Effect": "Allow", "Action": [ "ec2:*" ], "Resource": [ "arn:aws:ec2:us-east-1:<MYACCOUNTHERE>:security-group/*" ] } ] }
但是,当我用IAM用户login时,我在安全组页面上收到一条消息:“您无权执行此操作”。
我知道用户/组正在工作,因为如果我select“Amazon EC2 Full Access”的IAM策略模板,用户可以访问EC2中的所有内容。
我显然没有很多与IAM的经验,任何帮助将不胜感激。
为了这个工作,你需要明确允许以下内容:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1392679134000", "Effect": "Allow", "Action": [ "ec2:AuthorizeSecurityGroupEgress", "ec2:AuthorizeSecurityGroupIngress", "ec2:CreateSecurityGroup", "ec2:DeleteSecurityGroup", "ec2:DescribeInstanceAttribute", "ec2:DescribeInstanceStatus", "ec2:DescribeInstances", "ec2:DescribeNetworkAcls", "ec2:DescribeSecurityGroups", "ec2:RevokeSecurityGroupEgress", "ec2:RevokeSecurityGroupIngress" ], "Resource": [ "*" ] } ] }
上面的JSON策略基本上规定用户只能访问上面的内容。 他们将无法访问其他任何东西。 这包括ec2实例,S3,IAM,cloudfront等
如果你想限制编辑到一个单一的安全组,我认为你需要2个语句,以下为我工作:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1413232782000", "Effect": "Allow", "Action": [ "ec2:DescribeInstanceAttribute", "ec2:DescribeInstanceStatus", "ec2:DescribeInstances", "ec2:DescribeNetworkAcls", "ec2:DescribeSecurityGroups" ], "Resource": [ "*" ] }, { "Sid": "Stmt1413232782001", "Effect": "Allow", "Action": [ "ec2:AuthorizeSecurityGroupEgress", "ec2:AuthorizeSecurityGroupIngress", "ec2:RevokeSecurityGroupEgress", "ec2:RevokeSecurityGroupIngress" ], "Resource": [ "arn:aws:ec2:us-east-1:<accountid>:security-group/sg-<id>" ] } ] }
DescribeInstance可能不需要,但在我的情况下,我想要它,所以没有testing没有它
看起来您的安全组可能正在被实例或其他EC2资源使用。 你可以尝试:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1392336685000", "Effect": "Allow", "Action": [ "ec2:*" ], "Resource": [ "arn:aws:ec2:us-east-1:<MYACCOUNTHERE>:instance/*", "arn:aws:ec2:us-east-1:<MYACCOUNTHERE>:security-group/*" ] } ] }
我正在寻找一个问题的答案@ nsij22在接受的答案的评论中问。 不幸的是,看起来是不可能的。 根据IAM策略模拟器 ,只有来自@ DevMan14的答案的以下动作可以与特定的资源一起使用:
对于其他一切,IAM策略模拟器说:
此操作不支持资源级权限。 授予访问权限的策略必须在资源元素中指定“*”。
它看起来像这样:
。
所有“允许”和“拒绝”都是一样的,所以我把它们倒塌了。