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
已提问 2 个月前507 查看次数
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
专家
已回答 2 个月前
profile picture
专家
已审核 1 个月前
0

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

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

yuuka_u
已回答 2 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则