7

我正在尝试在我的 Amazon Linux 中下载 AWS Codedeploy 代理文件。我按照http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-run-agent.html中提到的说明,为 Amazon Linux 创建了适当的实例配置文件、服务角色等。一切都是最新的(Amazon Linux,CLI Packages,它是一个全新的实例,我已经尝试了至少 3 个以上的全新实例,结果相同)。所有实例都具有完整的出站 Internet 访问权限。

但以下从 S3 下载安装的语句总是失败,

aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . --region us-east-1

出现错误,调用 HeadObject 操作时发生客户端错误 (403):禁止完成 1 个部分,剩余 ... 文件

谁能帮我解决这个错误?

4

2 回答 2

17

我发现了问题,根据 IAM Instance profile 的 Codedeploy 文档

http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-create-iam-instance-profile.html

需要为您的 IAM 实例配置文件授予以下权限。

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "s3:Get*",
        "s3:List*"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}

但是我将资源限制在我的代码存储桶中,因为我不希望我的实例直接访问其他存储桶。但事实证明,我还需要为 aws-codedeploy-us-east-1/* s3 资源提供额外的权限,以便能够下载代理。这在为 Codedeploy 设置 IAM 实例配置文件的文档中不是很清楚。

于 2014-11-20T06:33:05.937 回答
2

更有效的限制性政策:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:Get*",
                "s3:List*"
            ],
            "Resource": [
                "arn:aws:s3:::aws-codedeploy-us-east-1/*",
                "arn:aws:s3:::aws-codedeploy-us-west-1/*",
                "arn:aws:s3:::aws-codedeploy-us-west-2/*",
                "arn:aws:s3:::aws-codedeploy-ap-south-1/*",
                "arn:aws:s3:::aws-codedeploy-ap-northeast-2/*",
                "arn:aws:s3:::aws-codedeploy-ap-southeast-1/*",
                "arn:aws:s3:::aws-codedeploy-ap-southeast-2/*",
                "arn:aws:s3:::aws-codedeploy-ap-northeast-1/*",
                "arn:aws:s3:::aws-codedeploy-eu-central-1/*",
                "arn:aws:s3:::aws-codedeploy-eu-west-1/*",
                "arn:aws:s3:::aws-codedeploy-sa-east-1/*"
            ]
        }
    ]
}
于 2016-07-23T16:20:54.200 回答