Search code examples
amazon-web-servicesrestweb-scrapingamazon-elasticache

AWS Elasticache price list REST api for us-west-1 region of On-Demand nodes


I want the cost information node type and price per hour in the form of JSON or CSV. Do AWS already provide this information as REST endpoint?.

Or do I have to scrape the below web page to get the required information?.

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


Solution

  • Sure there's an API for that (it's AWS, there's almost always an API). Here's how you can get the pricing by regions.

    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']}")
    

    This yields:

    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
    ...