64 words
1 minute
Display EC2 instance costs per month

Display EC2 instance costs per month#

The EC2 pricing page shows cost per hour, which is pretty much useless. I want cost per month. The following JavaScript, pasted into the browser developer console, modifies the page to show cost-per-month instead.

Array.from(
document.querySelectorAll('td')
).filter(
el => el.textContent.toLowerCase().includes('per hour')
).forEach(
el => el.textContent = '$' + (parseFloat(
/\d+\.\d+/.exec(el.textContent)[0]
) * 24 * 30).toFixed(2) + ' per month'
)
Display EC2 instance costs per month
https://mranv.pages.dev/posts/display-ec2-instance-costs-per-month/
Author
Anubhav Gain
Published at
2024-12-21
License
CC BY-NC-SA 4.0