OpenSearchの単価をlambdaで取得したい。

0

lambda内でboto3を利用してAWSのサービスの現在の単価を取得したい。
pricing_client = boto3.client('pricing', region_name='us-east-1')

●OpenSearchの単価を取得しようと思った時

  response = pricing_client.get_products(ServiceCode='AmazonOpenSearchService')

上記の時はresponseの中身は下記のようにPriceListが空欄である。

{'FormatVersion': 'aws_v1', 'PriceList': [],{'FormatVersion': 'aws_v1', 'PriceList': [],…}

● EC2の単価を取得しようと思った時

response = pricing_client.get_products(ServiceCode='AmazonEC2')

上記の時はreponseの中身は下記のようにPriceListの中身が確認可能である。

{'FormatVersion': 'aws_v1', 'PriceList': ['{"product":{"productFamily":"Compute Instance","a…}

OpenSearchの方は単価を取得できないのでしょうか。

yuuka_u
質問済み 1ヶ月前498ビュー
2回答
1
承認された回答

AWS CLIでAmazonOpenSearchServiceというサービスコードを探したのですが見つかりませんでした。
https://docs.aws.amazon.com/ja_jp/awsaccountbilling/latest/aboutv2/price-list-query-api-find-services.html

aws pricing describe-services --region us-east-1 --query "Services"[]."ServiceCode" --service-code AmazonOpenSearchService

昔はAmazon Elasticsearchという名前だったのでその名残でAmazonESがサービスコードなのではないかと思います。
https://aws.amazon.com/jp/blogs/news/amazon-elasticsearch-service-is-now-amazon-opensearch-service-and-supports-opensearch-10/

以下のコマンドを実行すると結果が返ってくるのでサービスコードをAmazonESに変更して実行してみてください。

aws pricing describe-services --region us-east-1 --query "Services"[]."ServiceCode" --service-code AmazonES
[
    "AmazonES"
]
profile picture
エキスパート
回答済み 1ヶ月前
profile picture
エキスパート
レビュー済み 1ヶ月前
0

Riku_Kobayashiさん、早速の回答ありがとうございます! AmazonESに変更したところ、無事PriceListの中身を取得することが出来ました!

とても早く解決できて、大変助かりました。ありがとうございました。

yuuka_u
回答済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン