2016-07-16 46 views
1

我正在使用AWS執行我的第一步並嘗試使用AWS CLI將文件從EC2服務器複製到S3服務器。AWS CLI'cp'失敗並顯示「指定的存儲桶不存在」

我收到錯誤:

A client error (NoSuchBucket) occurred when calling the PutObject operation: The specified bucket does not exist

我的命令如下:
- 我去我S3儀表盤,所選擇的桶 - >特性和copeied的「端點」值,它是

[bucket name].s3-website-us-west-2.amazonaws.com

  • 然後執行

aws s3 cp ./file.ext s3://[bucket name].s3-website-us-west-2.amazonaws.com/file.ext

但是由於之前描述的錯誤 - 桶不存在而失敗。

p.s.運行

aws s3api list-buckets --query 'Buckets[].Name'

顯示存儲桶確實存在,因此這不是我理解的問題。

編輯 如果我不使用的端點,但只能用水桶命名錯誤消息鼓勵使用全名,其在所有網上的例子看起來酷似端點

upload failed: ./file.ext to s3://[bucket name]/file.ext A client error (PermanentRedirect) occurred when calling the PutObject operation: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint: [bucket name].s3.amazonaws.com You can fix this issue by explicitly providing the correct region location using the --region argument, the AWS_DEFAULT_REGION environment variable, or the region variable in the AWS CLI configuration file. You can get the bucket's location by running "aws s3api get-bucket-location --bucket BUCKET".

+0

桶的名稱是什麼? – error2007s

+0

可以稱之爲bucket_name - 如果這就是你要求的全部小寫,請以x.com形式 – AYBABTU

+0

注意尾部斜線 – grepe

回答

5

你是使用桶的端點不要使用它。使用桶的實際名稱。檢查語法bucket name應該只是存儲桶的名稱,而不是存儲桶的端點或URL。

aws s3 cp --recursive ./file.txt s3://bucketname/ 

上述錯誤是由於策略問題導致您沒有該操作的正確權限。查看本指南可將策略添加到AWS S3存儲桶。

http://blogs.aws.amazon.com/security/post/Tx3VRSWZ6B3SHAV/Writing-IAM-Policies-How-to-grant-access-to-an-Amazon-S3-bucket

-1

不知道爲什麼,我試圖用形式做任何工作 - 看我的編輯 - 我試圖按照該建議,但失敗。

我解決它同時運行的方式,如然後,使用的

s3://[bucket name] --region=[return_val_of_get_bucet_location]

形式。如果任何人都可以對沒有標誌,我會欣賞它運行勸勸

aws s3api get-bucket-location --bucket BUCKET

+0

請檢查我編輯的答案。 – error2007s

+2

aws-cli需要大部分操作的區域。您可以[設置默認區域](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-quick-configuration),但您始終必須指定該地區的方式或其他。 –