メンチカツには醤油でしょ!!

AWS/Java/Node.js/Spreadsheets/Docker/Jenkins/コミュニティ・勉強会レポを主とした技術系ブログ

S3バケット作成時にThe requested bucket name is not available.

こんなエラー

バケットの作成 - バケット名とリージョンの選択

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.

バケットとは、Amazon S3 に格納されるオブジェクトのコンテナです。バケットを作成する場合、レイテンシーを最適化し、コストを最小限に抑えて規制要件に対応できるリージョンを選ぶことが可能です。バケットの命名ルールに関する詳細については、『Amazon S3 ドキュメント』を参照してください。

AWS CLIだとこんな感じ

$ aws s3 mb s3://already-exists-bucket-name
make_bucket failed: s3://already-exists-bucket-name An error occurred (BucketAlreadyExists) 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.

CLIの方がエラーメッセージは親切ですね(笑)

原因はかんたん

バケット名はAWS内でユニークでなければなりません(重複が許されません)
また、バケット名はリージョンが違ってもエラーは出ます。 

なので、tempとか適当な名前だとエラーになりますね。

なので、私はいつもドメイン名を付けるようにしています。
ドメイン名がmy-domain-name.comだとすると、
my-domain-name.com.bucket-name
bucket-name.my-domain-name.com
のような感じです。

ちなみに

$ aws s3 mb bucket-name-you-want-to-create

<S3Uri>
Error: Invalid argument type

この場合はs3://が抜けてるケアレスミスです。

$ aws s3 mb s3://bucket-name-you-want-to-create

こうですね。