How to download all the AWS pricing in bash

Hello, this bash one-liner needs bash, a correctly configured AWS CLI, wget, jq and that’s it.

The script will:

  1. Download the master file
  2. Parse the json file with jq extracting, for each product, the url of the current version
  3. Create a folder hierarchy with the name of the product (done by the settings of wget)
  4. Save the pricing, in that directory

For example the pricing of AmazonQLDB will be in the folder AmazonQLDB/current/

JSON

wget -q -O - https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/index.json  | jq -r '.offers[].currentVersionUrl'  | wget -x  --base="https://pricing.us-east-1.amazonaws.com" --no-host-directories --cut-dirs=3 -i -

CSV

wget -q -O - https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/index.json  | jq -r '.offers[].currentVersionUrl' | sed 's/\.json$/.csv/' | wget -x  --base="https://pricing.us-east-1.amazonaws.com" --no-host-directories --cut-dirs=3 -i -
comments powered by Disqus