如何生成用于制作快照的 IAM 策略?

juu*_*uga 8 amazon-ec2 amazon-web-services amazon-iam

我在 EC2 实例上安装了卷,我想为其制作快照。

我使用以下策略创建了一个新的 IAM 用户:

{
  "Statement": [
    {
      "Sid": "...",
      "Effect": "Allow",
      "Action": [
        "ec2:CreateSnapshot",
        "ec2:CreateTags",
        "ec2:DeleteSnapshot",
        "ec2:DescribeAvailabilityZones",
        "ec2:DescribeSnapshots",
        "ec2:DescribeTags",
        "ec2:DescribeVolumeAttribute",
        "ec2:DescribeVolumeStatus",
        "ec2:DescribeVolumes"
      ],
      "Resource": [
        "arn:aws:ec2:eu-west-1:MY_USER_ID"
      ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我已将访问密钥和秘密添加到我的~/.bashrc并获取了它。当我运行时,ec2-describe-snapshots我得到以下响应:Client.UnauthorizedOperation: You are not authorized to perform this operation.

当我"Resource"刚刚的时候,"*"我能够列出所有类型的亚马逊快照。我希望创建该eu-west-1地区只有我自己拥有/可见的快照。

小智 7

正如如何限制 EC2 描述图像权限中明智地发布的那样,根本没有在ec2:Describe*操作上实现资源级别的权限。

实际上,您需要根据其他事物而不是资源 ARN 来限制访问。