aws s3 cp返回调用HeadObject操作时发生错误(403):禁止

Ale*_*nko 5 amazon-s3 amazon-web-services

前言

我想这可能是重复的,但其他有相同问题的帖子并没有太大帮助。

一个问题

aws s3 cp s3://s3-us-west-2.amazonaws.com/my-test-bucket/intro.jpg test.jpg
输出以下内容:
fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden

值区政策:

{
    "Version": "2012-10-17",
    "Id": "Policy1539624480514",
    "Statement": [
        {
            "Sid": "Stmt1539624478431",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::my-test-bucket",
                "arn:aws:s3:::my-test-bucket/*"
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud) 一些注意事项
  1. intro.jpg 是由用户A(具有AdministratorAccess)通过AWS Console仪表板添加的(不是在存储桶之间复制文件)
  2. aws sts get-caller-identity 向我返回有关用户A的信息

    {
        "Version": "2012-10-17",
        "Id": "Policy1539624480514",
        "Statement": [
            {
                "Sid": "Stmt1539624478431",
                "Effect": "Allow",
                "Principal": "*",
                "Action": "s3:*",
                "Resource": [
                    "arn:aws:s3:::my-test-bucket",
                    "arn:aws:s3:::my-test-bucket/*"
                ]
            }
        ]
    }
    
    Run Code Online (Sandbox Code Playgroud)

  3. cat ~/.aws/config

{
    "UserId": "AIDXXXX3KDQHYYYYXRLO",
    "Account": "765123991235",
    "Arn": "arn:aws:iam::765123991235:user/john.doe@example.com"
}
Run Code Online (Sandbox Code Playgroud)

  1. cat ~/.aws/credentials 指向用户A访问密钥和机密

[default]
region = us-west-2
output = json
Run Code Online (Sandbox Code Playgroud)

  1. aws s3 ls 返回正确的桶列表
  2. 时间已在我的本地计算机上正确同步

Mic*_*bot 6

s3://s3-us-west-2.amazonaws.com/my-test-bucket/intro.jpg指的是一个名为的存储桶s3-us-west-2.amazonaws.com和对象键my-test-bucket/intro.jpg

拒绝访问,因为那不是您的存储桶。

正确的URI是s3://my-test-bucket/intro.jpg