我尝试使用AWS-CLI将文件从本地复制到S3存储桶。 这是我的命令:
aws s3 cp /path/to/local/file s3://bucket-name
但是我得到的消息是:
An error occured (AccessDenied) when calling the PutObject operation: Access Denied
我已在s3存储桶中设置了策略以接受所有内容,如下所示:
{
"Id": "BucketPolicy",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllAccess",
"Action": "s3:*",
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::MyBucket",
"arn:aws:s3:::MyBucket/*"
],
"Principal": "*"
}
]
}
出现此错误的原因可能是什么?
任何帮助将不胜感激!
答案 0 :(得分:0)
aws s3 cp test.txt s3://mybucket/test2.txt
基本存储桶策略aws s3 docs
此策略允许所有用户检索MyBucket中的任何对象。它还向AWS帐户1234-5678-9012的 root 用户授予放置和删除权限。
{
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::MyBucket/*"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:root"
},
"Action": [
"s3:DeleteObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::MyBucket/*"
}
]
}