-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathlistcgfamis.sh
37 lines (27 loc) · 1.22 KB
/
listcgfamis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
#PAYG='https://aws.amazon.com/marketplace/pp/B010GKMEKW'
#BYOL='https://aws.amazon.com/marketplace/pp/B014GECC1A'
#Metered='https://aws.amazon.com/marketplace/pp/B077G9FKK7'
#set the version and build number and then run the script
VERSION='800-0475'
ami_regions=($(aws ec2 describe-regions --output text | sed -e 's/^.*com[[:blank:]]//'))
num_regions=${#ami_regions[@]}
for i in "${ami_regions[@]}"
do
filter='Name=name,Values=CudaCGFHourly-v'"$VERSION"'*'
PAYGAMI=$(aws ec2 describe-images --owner aws-marketplace --region $i --filters $filter --query 'Images[-1].{ID:ImageId}' --output text)
echo "\"$i\" : {"
echo " \"Hourly\" : \"$PAYGAMI\","
filter='Name=name,Values=CudaCGFBYOL-v'"$VERSION"'*'
BYOLAMI=$(aws ec2 describe-images --owner aws-marketplace --region $i --filters $filter --query 'Images[-1].{ID:ImageId}' --output text)
echo " \"BYOL\" : \"$BYOLAMI\","
filter='Name=name,Values=CudaCGFMetered*v'"$VERSION"'*'
METEREDAMI=$(aws ec2 describe-images --owner aws-marketplace --region $i --filters $filter --query 'Images[-1].{ID:ImageId}' --output text)
echo " \"Metered\" : \"$METEREDAMI\""
if [[ $i == ${ami_regions[${#ami_regions[@]}-1]} ]]
then
echo "}"
else
echo "},"
fi
done