Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bash-friendly ec2 prices
#!/usr/bin/env bash
(echo 'function callback(data) { console.log(JSON.stringify(data)); }'; curl -s "$URL") |\
node |\
jq -r '.config.regions[] |
select(.region == "us-east-1") |
.instanceTypes[] |
( .terms[] | select(.term == "yrTerm1") | .onDemandHourly[].prices.USD ),
.terms[] | select(.term == "yrTerm1") | .purchaseOptions |
map(.valueColumns[] | select(.name == "effectiveHourly") | .prices.USD)[]
.terms[] | select(.term == "yrTerm3") | .purchaseOptions |
map(.valueColumns[] | select(.name == "effectiveHourly") | .prices.USD)[]
] |
Copy link

michael-gracy commented Sep 13, 2016

This is great, but when listing the t2.nano, the columns aren't aligned. I'd fix it, but I'm not node.js experienced. :-(

Copy link

abcarroll commented Nov 28, 2016


See my updated version:

  • Fixes where amazon changed json node keys to to "yrTerm1Standard" .. etc and broke it entirely
  • Also fixes the nano alignment issue

Note to anyone interested, these files are available for all AWS services that I can find.... But not all easily compatible/using the same node tree.

Just go to the AWS pricing page of your choice and view source, and find "data-model". You will find one file for every single PricingTable/Tab combo. For example MySQL standard deployments (single AZ) is:

One small possible positive note -- it seems the URL/filenames themselves do follow a bit of a pattern. So it should be easy to generate them. If you had time and a little more powerful of a programming language, you could do great things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment