Skip to content

Instantly share code, notes, and snippets.

@rootfs
Last active January 31, 2024 06:36
Show Gist options
  • Select an option

  • Save rootfs/49855d0c75ef8a27e494eda6eb928aab to your computer and use it in GitHub Desktop.

Select an option

Save rootfs/49855d0c75ef8a27e494eda6eb928aab to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get the list of x86 metal instance types
instance_types=$(aws ec2 describe-instance-types --region us-east-2 --filters "Name=instance-type,Values=*metal*" --output json | jq '.InstanceTypes[] | select(.SupportedUsageClasses | index("spot")) | select(.ProcessorInfo.SupportedArchitectures | index("x86_64")) | .InstanceType' -r)
# Loop through each instance type and get the spot price
for instance_type in $instance_types; do
spot_price=$(aws ec2 describe-spot-price-history --region us-east-2 --instance-types $instance_type --product-descriptions "Linux/UNIX (Amazon VPC)" --query "SpotPriceHistory[0].SpotPrice" --output text)
echo "Instance Type: $instance_type, Spot Price: $spot_price"
done
@rootfs
Copy link
Author

rootfs commented Jan 11, 2024

sh aws_price.sh |sort -k 6 -g

Instance Type: m5zn.metal, Spot Price: 0.489800
Instance Type: z1d.metal, Spot Price: 0.519000
Instance Type: i3.metal, Spot Price: 0.595200
Instance Type: m5dn.metal, Spot Price: 0.947000
Instance Type: m5n.metal, Spot Price: 0.956300
Instance Type: c5d.metal, Spot Price: 0.993000
Instance Type: c7i.metal-24xl, Spot Price: 1.050300
Instance Type: i3en.metal, Spot Price: 1.116400
Instance Type: m7i.metal-24xl, Spot Price: 1.176300
Instance Type: c5n.metal, Spot Price: 1.178000
Instance Type: r7iz.metal-16xl, Spot Price: 1.215200
Instance Type: x2idn.metal, Spot Price: 1.333800
Instance Type: c5.metal, Spot Price: 1.507000
Instance Type: r7i.metal-24xl, Spot Price: 1.531300
Instance Type: m5.metal, Spot Price: 1.619400
Instance Type: m6a.metal, Spot Price: 1.696900
Instance Type: c6in.metal, Spot Price: 1.726300
Instance Type: c6id.metal, Spot Price: 1.743000
Instance Type: c6a.metal, Spot Price: 1.792300
Instance Type: r5.metal, Spot Price: 1.833400
Instance Type: r5d.metal, Spot Price: 1.914400
Instance Type: c7i.metal-48xl, Spot Price: 1.932500
Instance Type: m5d.metal, Spot Price: 1.951000
Instance Type: i4i.metal, Spot Price: 2.005600
Instance Type: m6in.metal, Spot Price: 2.069500
Instance Type: c6i.metal, Spot Price: 2.113900
Instance Type: m6id.metal, Spot Price: 2.138800
Instance Type: r5n.metal, Spot Price: 2.158000
Instance Type: r5b.metal, Spot Price: 2.172500
Instance Type: r6a.metal, Spot Price: 2.199800
Instance Type: m7i.metal-48xl, Spot Price: 2.258100
Instance Type: r7iz.metal-32xl, Spot Price: 2.386900
Instance Type: r6id.metal, Spot Price: 2.422500
Instance Type: c7a.metal-48xl, Spot Price: 2.449800
Instance Type: r5dn.metal, Spot Price: 2.467300
Instance Type: m7a.metal-48xl, Spot Price: 2.483000
Instance Type: m6i.metal, Spot Price: 2.502400
Instance Type: r6idn.metal, Spot Price: 2.552100
Instance Type: x2iedn.metal, Spot Price: 2.667600
Instance Type: r6i.metal, Spot Price: 2.703900
Instance Type: m6idn.metal, Spot Price: 2.813300
Instance Type: r7i.metal-48xl, Spot Price: 2.952300
Instance Type: r6in.metal, Spot Price: 3.149300
Instance Type: g4dn.metal, Spot Price: 3.155100
Instance Type: r7a.metal-48xl, Spot Price: 3.541600

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment