Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michael-gracy/71c6675b7b0e21daa5a1b26af338ac6b to your computer and use it in GitHub Desktop.
Save michael-gracy/71c6675b7b0e21daa5a1b26af338ac6b to your computer and use it in GitHub Desktop.
Bash-friendly ec2 prices
#!/usr/bin/env bash
URL="http://a0.awsstatic.com/pricing/1/ec2/ri-v2/linux-unix-shared.min.js"
(echo 'function callback(data) { console.log(JSON.stringify(data)); }'; curl -s "$URL") |\
node |\
jq -r '.config.regions[] |
select(.region == "us-east-1") |
.instanceTypes[] |
[
.type,
( .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)[]
)
] |
join("\t")
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment