Created
October 19, 2020 08:57
-
-
Save corupta/0675ef1d28ed7d7121c0c52165f78c36 to your computer and use it in GitHub Desktop.
AWS EC2 Pricing Sort By Price
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// go to https://aws.amazon.com/ec2/pricing/on-demand/ and run this in console | |
(() => { | |
let table = document.querySelector('div.js-active').children[0]; | |
let bodies = table.getElementsByTagName('tbody'); | |
bodies = Array.from(bodies); | |
bodies = bodies.map((b) => Array.from(b.children)); | |
let rows = bodies.reduce((acc, x) => [...acc, ...Array.from(x.slice(1)).map((r) => [x[0].children[0].innerText, ...Array.from(r.children).map((c) => c.innerText)])], []); | |
let data = rows.map(([type, name, vcpu, ecu, memory, storage, price]) => ({ name, vcpu, ecu, memory, storage, price, type })); | |
data.sort(({ price: priceA }, { price: priceB }) => parseFloat(priceB.substr(1)) - parseFloat(priceA.substr(1))); | |
data.forEach(({name, vcpu, ecu, memory, storage, price, type }) => console.log(`price: ${price} name: ${name} - vcpus: ${vcpu} - ecu: ${ecu} - memory: ${memory} - storage: ${storage} - type: ${type}`)); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment