Dar*_*ook 5 amazon-s3 amazon-web-services aws-cli
更新:第二天一切正常!?!所以我认为答案可能是您必须等待一段时间,无论是在创建新的 IAM 用户之后,还是在创建新的存储桶之后,上传才能工作。
我创建了一个专用的 IAM 用户,然后做了aws configure
,并给出了密钥,并指定了“eu-west-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.
Run Code Online (Sandbox Code Playgroud)
问题不仅仅是大文件。我制作了一个 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
Run Code Online (Sandbox Code Playgroud)
尝试aws s3 ls s3://backup-specialtest
给了我:
A client error (AccessDenied) occurred when calling the ListObjects operation: Access Denied
Run Code Online (Sandbox Code Playgroud)
尝试aws s3api get-bucket-acl --bucket backup-specialtest
给了我:
A client error (AccessDenied) occurred when calling the GetBucketAcl operation: Access Denied
Run Code Online (Sandbox Code Playgroud)
我已经在 AWS Web 控制台中将“AmazonS3FullAccess”策略附加到我的用户。当我点击显示政策时,我得到:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
看起来不错:他可以在所有资源上执行所有 S3 操作。
在写这篇文章时,我想我会仔细检查我是否仍然可以创建一个新的存储桶,并且一路上没有破坏任何东西。所以我尝试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.
Run Code Online (Sandbox Code Playgroud)
但是当我尝试时:aws s3 mb s3://another-test-2
我成功了:
make_bucket: s3://another-test-2/
Run Code Online (Sandbox Code Playgroud)
它就在那里: 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
Run Code Online (Sandbox Code Playgroud)
(最后一个存储桶似乎是由 root 用户在去年创建的,并且是空的。)
首先,您需要了解存储桶名称在整个亚马逊域中是唯一的。因此,如果用户已有一个名为“backup”的存储桶,您将无法使用该名称创建新存储桶。
也就是说,您有两种主要方法来管理存储桶的权限。
否则,您也可以使用存储桶策略(与上面提到的权限相同的地方)。您可以在此处找到存储桶策略示例。举个例子,像这样的东西应该让你的存储桶公开:
{"Version": "2012-10-17",
"Statement": [
{
"Sid": "myPolicy",
"Effect": "Allow",
"Principal": "*",
"Action": "*",
"Resource": [
"arn:aws:s3:::YOUR_BUCKET_NAME/*",
"arn:aws:s3:::YOUR_BUCKET_NAME"
]
}
]}
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
8993 次 |
最近记录: |