リージョンが異なるバケットにデータをコピーしようと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}
まぁ例によってドキュメントにはちゃんとかいてあるんですけどね。