我想可能是重复的,但是其他有相同问题的帖子并没有太大帮助。
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/*"
]
}
]
}
一些注意事项
intro.jpg
由用户A(具有AdministratorAccess)通过AWS Console仪表板添加(不是在存储桶之间复制文件) aws sts get-caller-identity
向我返回有关用户A的信息
{
"UserId": "AIDXXXX3KDQHYYYYXRLO",
"Account": "765123991235",
"Arn": "arn:aws:iam::765123991235:user/john.doe@example.com"
}
cat ~/.aws/config
[default]
region = us-west-2
output = json
cat ~/.aws/credentials
指向用户A访问密钥和机密
[default]
aws_access_key_id = AZZZIXXXXJQZA6YYYYUQ
aws_secret_access_key = 1/bbk3x4vr42r5c34s5c6A+enQK+yr5490234+9Y
aws s3 ls
返回正确的存储桶列表答案 0 :(得分:3)
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
。