LoginSignup
3
2

More than 3 years have passed since last update.

AWSリージョン名を Asia Pacific (Tokyo) や US East (N. Virginia) 等の形で取得

Last updated at Posted at 2019-11-19

タイトルの通りちょっと長い形のリージョン名が欲しいときは
SSM Parameter storeの以下のパスを参照すればよい。
/aws/service/global-infrastructure/regions/${REGION}/longName

  • ${REGION} には ap-northeast-1us-east-1 などが入る
  • どこのリージョンからでも任意のリージョンの情報を取得できる

例: AWS CLI

$ aws ssm get-parameters \
  --name '/aws/service/global-infrastructure/regions/ap-northeast-1/longName' \
  --output json|jq .Parameters[].Value
"Asia Pacific (Tokyo)"

例: boto3

import boto3

ssm = boto3.client('ssm')
res = ssm.get_parameters(
        Names = [
            '/aws/service/global-infrastructure/regions/ap-northeast-1/longName'
        ]
)
region = res['Parameters'][0]['Value']
print(region) # Asia Pacific (Tokyo)

つかいどころ

Price List APIのフィルター条件で使いました。
知っているといつか役に立つ日が来るかもしれません。

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