![プログラムで特定のリージョンで利用できるサービス一覧を取得する](https://images.ctfassets.net/ct0aopd36mqt/wp-thumbnail-cd6bca3e0ea12bce10d34b5c73117202/e7dcb00f209227795370c8effc01051d/aws-eyecatch.png)
プログラムで特定のリージョンで利用できるサービス一覧を取得する
目的
クラスメソッドタイランドの清水です。
2025年1月7日に AWS アジアパシフィック (タイ) リージョンが開始しました。
開始したばかりのリージョンのため、利用可能なサービスは他のリージョンよりも少ないです。
例えば、Amplify や IoT Core はまだありません。
ふとプログラムで利用可能なサービスリストを取得してみたいと思い、調べてみるといくつか方法があったのでご紹介します!
api.regional-table.region-services.aws.a2z.com から取得
https://api.regional-table.region-services.aws.a2z.com/index.json で取得できるみたいです。
ただし、この API がメンテナンスされているのか、どのような仕様なのかが見つけられなかったので、参考程度に使うのが良いかと思います。
curl と jq で以下のように特定のリージョンで利用可能なサービスリストを取得できます。
curl -s https://api.regional-table.region-services.aws.a2z.com/index.json | jq '.prices[] | select(.attributes."aws:region" == "ap-southeast-7") | .attributes."aws:serviceName"'
実行すると、このようにサービスリストが取得できました。
※ タイリージョンのリストを取得するため、 ap-southeast-7 を使っています。
Parameter Store から取得
以下のコマンドで Parameter Store の Public な Parameter でもサービスを取得できるようです。
aws ssm get-parameters-by-path --region ap-southeast-1 --path /aws/service/global-infrastructure/services --query 'Parameters[].Name | sort(@)'
ただし、タイリージョン(ap-southeast-7)を指定するとエラーが出ました。
まだタイリージョンにはこの Parameter が存在しないようです。
An error occurred (AccessDeniedException) when calling the GetParametersByPath operation: No access to "/aws/" namespace: aws/service/global-infrastructure is not a valid namespace
公式ドキュメントの(Documentation > AWS Systems Manager > User Guide)に使い方が紹介されています。
boto3 の get_available_services()
boto3 (Python の AWS SDK) に get_available_services() というメソッドを使うと取得できます。
import boto3
session = boto3.Session()
available_services = session.get_available_services()
こちらが実行結果です。
get_available_services はサービス名の List[str] を返すようですね。
詳しい使い方は boto3 ドキュメント に記載されています。
番外編
プログラムでの取得ではありませんが、AWS について /グローバルインフラストラクチャ / AWS サービス (リージョン別) でも利用可能なサービス一覧を取得することができます。
まとめ
今回は様々な方法でプログラムで利用できるサービス一覧を取得する方法をご紹介しました。
参考リンク
- https://dev.classmethod.jp/articles/try-to-use-ap-southeast-7-thailand-region/
- https://aws.amazon.com/jp/about-aws/global-infrastructure/regional-product-services
- https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-public-parameters-global-infrastructure.html
- https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html#boto3.session.Session.get_available_services