LoginSignup
2
2

More than 1 year has passed since last update.

AWS CLI 「us-east-1」で s3api CreateBucketできない(Udemy SysOps問題集① ラボ試験問題2 / 質問72)

Last updated at Posted at 2022-02-27

Udemy SysOps問題集① ラボ試験問題2 / 質問72にてS3バケットのレプリケーション先を作成する問題があるのですが、解答のコマンドが通りませんでした。この記事ではその原因を追求していきます。

該当コマンド

aws s3api create-bucket --bucket 【バケット名】 --region us-east-1 --create-bucket-configuration LocationConstraint=us-east-1

エラー

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

そんなリージョンないよ!的なことがかかれてます...

検証

①us-east-1以外のリージョン(ap-northeast-1)で作ってみる→できた
②マネコンからus-east-1にバケット作って見る→できた

これらからs3apiコマンド限定で、
us-east-1が通っていないということがわかりました。

調査

ちょっと調べてるみると良記事を発見。
https://jpcodeqa.com/q/ba30fc10a5c454acda2fae5eee2198fc

検証で作ったバケットに対してそれぞれリージョンを取得してみると...

ap-northeast-1のバケット

$ aws s3api get-bucket-location --bucket 【バケット名】
{
    "LocationConstraint": "ap-northeast-1"
}

ほうほう そうだよね

us-east-1のバケット

aws s3api get-bucket-location --bucket 【バケット名】
{
    "LocationConstraint": null
}

なるほど...
LocationConstraint では取得できないみたいですね。

公式ドキュメントにも記載がありました。

As shown above, the value of the LocationConstraint member in the output JSON is the expected region of the bucket, eu-central-1. Note that for buckets created in the US Standard region, us-east-1, the value of LocationConstraint will be null. As a quick reference to how location constraints correspond to regions, refer to the AWS Regions and Endpoints Guide.

ラボ試験の問題はハンズオンする人多いだろうから、
通らないコマンドが解答のこの問題はちょっと不親切かもしれないですね...

2
2
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
2
2