如何使用 Boto3 AWS 中的定价 API 查找不同 RDS 实例 类 的价格?

How do I find the Prices for different RDS Instance Classes using the Pricing API in Boto3 AWS?

因此,我开始尝试查找 RDS 实例的服务代码,以用于定价 API 的 .get_products() 方法。但是当我使用 .describe_servies() 并浏览那里的服务列表时,我找不到 RDS 实例的服务。那么有没有一种方法可以通过boto3找到每个rds实例的按需价格呢?

我试图复制这样的东西,但对于 rds:

编辑: 当我使用:

>>> import boto3
>>> client = boto3.client('pricing', region_name='us-east-1')
>>> response = client.describe_services()
>>> for x in response['Services']:
...     print(x['ServiceCode'])

我得到这个不包括 rds 的列表:

尝试

response = client.describe_services(
    ServiceCode="AmazonRDS"
)

您没有看到 AmazonRDS 打印的原因是响应可能包含 NextToken 而您忽略了它。阅读有关 NextToken 是什么以及如何使用它的文档。

P.S.: 对试图帮助你但没有义务这样做的人要有礼貌。