Skip to content

Instantly share code, notes, and snippets.

@ruanbekker
Last active November 16, 2020 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruanbekker/6e2b4d252b8c77841f8c131e2949d0f7 to your computer and use it in GitHub Desktop.
Save ruanbekker/6e2b4d252b8c77841f8c131e2949d0f7 to your computer and use it in GitHub Desktop.
AWS Price Difference between On-Demand and Spot

OnDemand:

$ curl -s https://raw.githubusercontent.com/powdahound/ec2instances.info/master/www/instances.json | jq -r '.[] | select(.instance_type == "t2.micro") | .pricing."eu-west-1".linux.ondemand'
0.0126

Spot:

$ aws --profile dev ec2 describe-spot-price-history --instance-types t2.micro --product-descriptions "Linux/UNIX" --max-items 1 | jq -r '.SpotPriceHistory[].SpotPrice'
0.003800

Note to self - Calculate a higher number from the current spot price:

$ spot_price=$(aws --profile dev ec2 describe-spot-price-history --instance-types t2.micro --product-descriptions "Linux/UNIX" --max-items 1 | jq -r '.SpotPriceHistory[].SpotPrice')
echo ${spot_price} 2 | awk '{printf "%4.3f\n",$1*$2}'
0.008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment