Amazon S3のバケット操作はバージニア北部だけ挙動が少し異なる

Amazon S3のバケット操作はバージニア北部だけ挙動が少し異なる

2025.04.30

こんにちは。サービス開発室の武田です。

普段東京リージョンばかり触っていて、たまに他のリージョンを触ると思いがけない仕様にあたったりするものですね。今回はAmazon S3バケットの仕様にあたりました。

まずは次のコマンドを見てください。

			
			$ aws s3api create-bucket --bucket my-test-bucket-ap-northeast-1-123456789012 --region ap-northeast-1 --create-bucket-configuration LocationConstraint=ap-northeast-1

		

これは問題なく成功します。また作成したバケットについてget-bucket-locationを実行してみると、次のような結果が返ってきます。

			
			$ aws s3api get-bucket-location --bucket my-test-bucket-ap-northeast-1-123456789012
{
    "LocationConstraint": "ap-northeast-1"
}

		

さて、同じことをバージニア北部でもやりたくなりました。もちろん次のようなコマンドを実行しますよね。

			
			$ aws s3api create-bucket --bucket my-test-bucket-us-east-1-123456789012 --region us-east-1 --create-bucket-configuration LocationConstraint=us-east-1

		

実はこのコマンドは失敗します。location-constraint is not validとかいわれちゃいます。

			
			An error occurred (InvalidLocationConstraint) when calling the CreateBucket operation: The specified location-constraint is not valid

		

正しいコマンド

正しくは次のようにする必要があります。us-east-1の場合はLocationConstraintを指定してはいけないんですね。

			
			$ aws s3api create-bucket --bucket my-test-bucket-us-east-1-123456789012 --region us-east-1

		

ちなみに、このバケットに対してget-bucket-locationをすると、次のようにnullが返ってきます。

			
			$ aws s3api get-bucket-location --bucket my-test-bucket-us-east-1-123456789012
{
    "LocationConstraint": null
}

		

まとめ

Amazon S3はバケットが全体で一意など、他のサービスに比べて異なる点がいくつかあります。APIで操作する際にも、リージョンによってパラメーターが変わる可能性もあるということを覚えておくといいですね。

この記事をシェアする

FacebookHatena blogX

関連記事