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
feita há 2 meses507 visualizações
2 Respostas
1
Resposta aceita

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
ESPECIALISTA
respondido há 2 meses
profile picture
ESPECIALISTA
avaliado há um mês
0

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

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

yuuka_u
respondido há 2 meses

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas