Created
August 29, 2024 12:49
-
-
Save ei-grad/10ac53d286247419b79ec5584bd28cfe to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Fetch instance types | |
instance_types=$(aws ec2 describe-instance-types --region us-east-1 \ | |
--filters "Name=processor-info.supported-architecture,Values=arm64_mac" \ | |
| jq -r '.InstanceTypes[].InstanceType' | sed 's/\.metal//g') | |
# Loop through each instance type and fetch pricing information | |
for instance_type in $instance_types; do | |
aws pricing get-products --service-code AmazonEC2 \ | |
--filters "Type=TERM_MATCH,Field=instanceType,Value=$instance_type" \ | |
| jq -r '.PriceList[]' | while read -r json_line; do | |
region=$(echo "$json_line" | jq -r '.product.attributes.regionCode') | |
type=$(echo "$json_line" | jq -r '.product.attributes.instanceType') | |
price=$(echo "$json_line" | jq -r '.terms.OnDemand[].priceDimensions[].pricePerUnit.USD') | |
# Print each row formatted | |
printf "%-15s %-15s %10s\n" "$type" "$region" "$price" | |
done | |
done | sort -k3 -V -b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment