[AWS] aws s3 sync ./upload_dir s3://xxx –region ap-northeast-1

aws-cli で command line 上から S3 へファイルアップロードしたところエラーが発生しました。

AWS | Amazon Web Services

% aws s3 sync ./upload_dir s3://backetname

エラーメッセージ

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.

デフォルト設定で region を設定しておらず、オプションでも未指定だったのが原因でした。

aws s3 sync ./upload_dir s3://backetname --region ap-northeast-1

–region ap-northeast-1 とか使ってる S3 のリージョンを指定することでアップロードできました。