微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

适用于按需节点us-west-1区域的AWS Elasticache价格表REST api

如何解决适用于按需节点us-west-1区域的AWS Elasticache价格表REST api

我希望成本信息节点类型和每小时价格为JSON或CSV形式。 AWS是否已提供此信息作为REST端点?。

还是我必须刮擦下面的网页才能获得所需的信息?。

https://aws.amazon.com/elasticache/pricing/

解决方法

当然有一个API(它是AWS,几乎总是有一个API)。这是按地区获取定价的方法。

import requests
url = "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/elasticache/USD/current/elasticache.json?timestamp=1598870451424"
r = requests.get(url).json()

for region in r["regions"].values():
    for k,v in region.items():
        print(k)
        print(f"{v['Instance Type']} - {v['price']}")

这将产生:

OnDemand Cache Instance Standard cache m3.2xlarge Memcached Previous Generation
cache.m3.2xlarge - 0.8550000000
OnDemand Cache Instance Standard cache m3.2xlarge Redis Previous Generation
cache.m3.2xlarge - 0.8550000000
OnDemand Cache Instance Standard cache m3.large Memcached Previous Generation
cache.m3.large - 0.2180000000
...

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。