PoeBlu / aws_prices

Fetch AWS Savings Plan prices into Excel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

aws_prices

Fetching AWS price quotes related to 3Y All Upfront Compute Savings Plan with output in an Excel file.

Installation

git clone git@github.com:longhorn09/aws_prices.git  
pip3 install xlsxwriter

Running

python3 index.py

Output

Python script will create an Excel file with Savings Plan quotes and filename of

sp_prices.xlsx

in same folder where python script is run. Can easily filter or use vlookup() or any other excel lookup technique such as xlookup() or index/match

Excel screenshot

Dependencies

Script relies up on xlsxwriter
This is for writing to Excel workbook. To install use pip3 as shown below

pip3 install xlsxwriter

Performance tweaks

Each regional savings plan URL ranges from 40~70 MB.
The list of EC2 offers is roughly 1.3GB. Even over gigabit fiber connections, it can take a while to download/read.
Because of this, if repeatedly running this script, save the 1.3GB JSON file locally, and toggle within the getSKUListLocal function and tweak the file name accordingly.

doLocal = True  # toggle

if (doLocal):
    # this is a 1.3 GB file - may take time
    with open('index_aws_ec2.json') as json_file: 
        myJSON = json.load(json_file)   

JSON reference snippets

3Y Compute Savings Plan All Upfront has product sku of RQRC4CUNT9HUG9WC

{
    "sku" : "RQRC4CUNT9HUG9WC",
    "productFamily" : "ComputeSavingsPlans",
    "serviceCode" : "ComputeSavingsPlans",
    "usageType" : "ComputeSP:3yrAllUpfront",
    "operation" : "",
    "attributes" : {
      "purchaseOption" : "All Upfront",
      "granularity" : "hourly",
      "purchaseTerm" : "3yr",
      "locationType" : "AWS Region",
      "location" : "Any"
    }
  }

Reference links

AWS Bulk API
Savings plan offer file
JSON Editor online
AmazonEC2.currentVersionUrl (1.3GB)
AmazonEC2.currentRegionIndexUrl
AmazonEC2.currentSavingsPlanIndexUrl

About

Fetch AWS Savings Plan prices into Excel


Languages

Language:Python 100.0%