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
asked 2 months ago507 views
2 Answers
1
Accepted Answer

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
EXPERT
answered 2 months ago
profile picture
EXPERT
reviewed a month ago
0

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

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

yuuka_u
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions