更新:第二天一切正常!?! 所以我认为答案可能是你需要等待一段时间,无论是在创build一个新的IAM用户之后,还是在创build一个新的桶之后,在上传之前都可以工作。
我创build了一个专门的IAM用户,然后做了一个aws configure ,并给出了密钥,并指定了“欧盟西部1”地区。 我可以在〜/ .aws / config中看到正确的信息。
我尝试过aws s3 mb s3://backup但被告知它已经存在。 aws s3 ls证实没有。 然而aws s3 mb s3://backup-specialtest确实有效。
但是,当我尝试aws s3 cp test.tgz s3://backup-specialtest我得到:
A client error (AccessDenied) occurred when calling the CreateMultipartUpload operation: Anonymous users cannot initiate multipart uploads. Please authenticate.
这不仅仅是大文件的问题。 我做了一个6字节的文本文件,并尝试上传aws s3 cp test.txt s3://backup-specialtest/但是得到:
upload failed: ./test.txt to s3://backup-specialtest/test.txt A client error (AccessDenied) occurred when calling the PutObject operation: Access Denied
aws s3 ls s3://backup-specialtest给了我:
A client error (AccessDenied) occurred when calling the ListObjects operation: Access Denied
aws s3api get-bucket-acl --bucket backup-specialtest给了我:
A client error (AccessDenied) occurred when calling the GetBucketAcl operation: Access Denied
我已经在AWS Web控制台中将“AmazonS3FullAccess”策略附加到我的用户。 当我点击显示策略时,我得到:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:*", "Resource": "*" } ] }
这看起来不错:他可以在所有资源上执行所有S3操作。
在写这篇文章的时候,我想我会仔细检查一下,我还可以创build一个新的存储桶,而且还没有破坏任何东西。 所以我试了一下aws s3 mb s3://another-test ,得到:
make_bucket failed: s3://another-test/ A client error (BucketAlreadyExists) occurred when calling the CreateBucket operation: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.
但是当我尝试: aws s3 mb s3://another-test-2我获得成功:
make_bucket: s3://another-test-2/
它在那里: aws s3 ls
2015-11-13 11:07:10 another-test-2 2015-11-13 10:18:53 backup-specialtest 2014-08-05 21:00:33 something-older
(最后一个桶似乎是由root用户在去年创build的,并且是空的。)
首先,您需要了解在整个亚马逊域中存储桶名称是唯一的。 因此,如果用户已经有一个名为“备份”的存储桶,则无法使用该名称创build新的存储桶。
这就是说,你有两个主要的方法来pipe理桶的权限。
否则,您也可以使用存储桶策略(与上述权限相同的地方)。 您将在这里find存储桶策略示例。 作为一个例子,像这样的东西应该让你的桶公开:
{"Version": "2012-10-17", "Statement": [ { "Sid": "myPolicy", "Effect": "Allow", "Principal": "*", "Action": "*", "Resource": [ "arn:aws:s3:::YOUR_BUCKET_NAME/*", "arn:aws:s3:::YOUR_BUCKET_NAME" ] } ]}