使用 S3 CLI 复制文件时访问被拒绝

使用 S3 CLI 复制文件时访问被拒绝

尝试使用 AWS CLI 拉取 S3 存储桶的内容时,我得到以下信息:

aws s3 cp --region us-east-1 s3://s3.amazonaws.com/my-bucket . --recursive
A client error (AccessDenied) occurred when calling the ListObjects operation: Access Denied
Completed 1 part(s) with ... file(s) remaining

类似地使用aws s3 sync也会失败。

用户策略是:

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

(我也尝试过各种限制较少的政策,但都无济于事)。

我尝试过空存储桶策略,也尝试过这个存储桶策略:

{
    "Id": "Policy1357935677554",
    "Statement": [
        {
            "Sid": "Stmt1357935647218",
            "Action": [
                "*"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::my-bucket",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::XXXXXXXXXX:user/my-user"
                ]
            }
        },
        {
            "Sid": "Stmt1357935676138",
            "Action": [
                "*"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::my-bucket/*",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::XXXXXXXXXX:user/my-user"
                ]
            }
        }
    ]
}

有趣的是,这工作:

aws s3api list-objects --region us-east-1 --bucket my-bucket

答案1

指定 s3 位置的格式s3://bucket/key如下,而不是s3://s3.amazonaws.com/my-bucket使用s3://my-bucket/

相关内容