Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Last active July 6, 2021 13:05
Show Gist options
  • Save matschaffer/4912279e49dce41ab9b2 to your computer and use it in GitHub Desktop.
Save matschaffer/4912279e49dce41ab9b2 to your computer and use it in GitHub Desktop.

Revisions

  1. matschaffer revised this gist Jun 11, 2015. 1 changed file with 20 additions and 5 deletions.
    25 changes: 20 additions & 5 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,23 @@
    (echo 'function callback(data) { console.log(JSON.stringify(data)); }'; curl -s 'http://a0.awsstatic.com/pricing/1/ec2/linux-od.min.js') |\
    #!/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 |
    map(.sizes)[][] |
    [.size, .valueColumns[].prices.USD] |
    join("\t")'
    .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")
    '
  2. matschaffer created this gist Jun 11, 2015.
    8 changes: 8 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    (echo 'function callback(data) { console.log(JSON.stringify(data)); }'; curl -s 'http://a0.awsstatic.com/pricing/1/ec2/linux-od.min.js') |\
    node |\
    jq -r '.config.regions[] |
    select(.region == "us-east-1") |
    .instanceTypes |
    map(.sizes)[][] |
    [.size, .valueColumns[].prices.USD] |
    join("\t")'