LoginSignup
3
1

More than 5 years have passed since last update.

s3 syncでリージョンの異なるバケットにデータをコピーする

Posted at

リージョンが異なるバケットにデータをコピーしようとs3 syncしたら以下のエラーが出力され、コピーされなかった。

A client error (PermanentRedirect) occurred when calling the ListObjects operation: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint: <コピー先バケット>
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".
Completed 1 part(s) with ... file(s) remaining
Build step 'Execute shell' marked build as failure
Finished: FAILURE

ちなみに使用したコマンドは次の通り

aws s3 sync s3://${SRC_BUCKET}/assets s3://${DST_BUCKET}/assets --delete 

どうやらコピー元とコピー先の両方のリージョンを指定する必要があるらしい。
というわけで次のように--source_regionにコピー元を指定して--regionにコピー先のリージョンを指定して実行したところ、うまくコピーできました。

aws s3 sync s3://${SRC_BUCKET}/assets s3://${DST_BUCKET}/assets --delete --source-region=${SRC_REGION} --region=${DST_REGION}

まぁ例によってドキュメントにはちゃんとかいてあるんですけどね。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1