■awscliでAZごとの料金リスト(t2.micro、t3-micro)を取得してみる
リージョン名を取得→AZをを取得→リージョンは「~/.aws/config」を書き換えつつ、1日前の料金表を取得。
$ cp .aws/config{,-back}
$ aws ec2 describe-regions --query 'Regions[].{Name:RegionName}' --output text | sort -k 1 | \
awk '{print "aws ec2 describe-availability-zones --query \047AvailabilityZones[].{Name:ZoneName}\047 --region "$1 \
" --output text"}' | sh | \
awk '{print " sed -i -e \047s/region = .*/region = "substr($1,1,length($1)-1)"/\047 ~/.aws/config;" \
" aws ec2 describe-spot-price-history" \
" --availability-zone "$1 \
" --start-time $(date -d \0471 days ago\047 -u \047+%Y-%m-%dT%H:%M:%S.000Z\047)" \
" --product-description \042Linux/UNIX\042" \
" --instance-types \042t2.micro\042 \042t3.micro\042" \
" --query \047SpotPriceHistory[].{InstanceType:InstanceType," \
"ProductDescription:ProductDescription,AvailabilityZone:AvailabilityZone,SpotPrice:SpotPrice}\047" \
" --output text"}' | sh > tn.micro-pricelist
$ cat tn.micro-pricelist
ap-northeast-1a t2.micro Linux/UNIX 0.004600
ap-northeast-1a t3.micro Linux/UNIX 0.004100
ap-northeast-1a t2.micro Linux/UNIX 0.004600
ap-northeast-1a t3.micro Linux/UNIX 0.004100
ap-northeast-1c t2.micro Linux/UNIX 0.004600
ap-northeast-1c t3.micro Linux/UNIX 0.004100
ap-northeast-1c t2.micro Linux/UNIX 0.004600
ap-northeast-1c t3.micro Linux/UNIX 0.004100
ap-northeast-1d t2.micro Linux/UNIX 0.004600
ap-northeast-1d t3.micro Linux/UNIX 0.004100
ap-northeast-1d t2.micro Linux/UNIX 0.004600
ap-northeast-1d t3.micro Linux/UNIX 0.004100
ap-northeast-2a t3.micro Linux/UNIX 0.003900
ap-northeast-2a t2.micro Linux/UNIX 0.004300
ap-northeast-2a t3.micro Linux/UNIX 0.003900
ap-northeast-2a t2.micro Linux/UNIX 0.004300
ap-northeast-2b t3.micro Linux/UNIX 0.003900
ap-northeast-2b t3.micro Linux/UNIX 0.003900
ap-northeast-2c t3.micro Linux/UNIX 0.003900
ap-northeast-2c t2.micro Linux/UNIX 0.004300
ap-northeast-2c t3.micro Linux/UNIX 0.003900
ap-northeast-2c t2.micro Linux/UNIX 0.004300
ap-northeast-2d t3.micro Linux/UNIX 0.003900
ap-northeast-2d t3.micro Linux/UNIX 0.003900
ap-northeast-3a t3.micro Linux/UNIX 0.004100
ap-northeast-3a t3.micro Linux/UNIX 0.004100
ap-northeast-3a t2.micro Linux/UNIX 0.004600
ap-northeast-3a t3.micro Linux/UNIX 0.004100
ap-northeast-3a t2.micro Linux/UNIX 0.004600
ap-northeast-3b t3.micro Linux/UNIX 0.004100
ap-northeast-3b t3.micro Linux/UNIX 0.004100
ap-northeast-3b t3.micro Linux/UNIX 0.004100
ap-northeast-3c t3.micro Linux/UNIX 0.004100
ap-northeast-3c t3.micro Linux/UNIX 0.004100
ap-northeast-3c t3.micro Linux/UNIX 0.004100
ap-south-1a t3.micro Linux/UNIX 0.003400
ap-south-1a t2.micro Linux/UNIX 0.003700
ap-south-1a t2.micro Linux/UNIX 0.003700
ap-south-1a t2.micro Linux/UNIX 0.003700
ap-south-1a t3.micro Linux/UNIX 0.003400
ap-south-1a t2.micro Linux/UNIX 0.003700
ap-south-1b t3.micro Linux/UNIX 0.003400
ap-south-1b t2.micro Linux/UNIX 0.003700
ap-south-1b t2.micro Linux/UNIX 0.003700
ap-south-1b t2.micro Linux/UNIX 0.003700
ap-south-1b t3.micro Linux/UNIX 0.003400
ap-south-1b t2.micro Linux/UNIX 0.003700
ap-south-1c t3.micro Linux/UNIX 0.003400
ap-south-1c t3.micro Linux/UNIX 0.003400
ap-southeast-1a t2.micro Linux/UNIX 0.004400
ap-southeast-1a t3.micro Linux/UNIX 0.004600
ap-southeast-1a t3.micro Linux/UNIX 0.004500
ap-southeast-1a t2.micro Linux/UNIX 0.004400
ap-southeast-1b t2.micro Linux/UNIX 0.004400
ap-southeast-1b t3.micro Linux/UNIX 0.004000
ap-southeast-1b t2.micro Linux/UNIX 0.004400
ap-southeast-1b t3.micro Linux/UNIX 0.004000
ap-southeast-1c t2.micro Linux/UNIX 0.004400
ap-southeast-1c t3.micro Linux/UNIX 0.004000
ap-southeast-1c t2.micro Linux/UNIX 0.004400
ap-southeast-1c t3.micro Linux/UNIX 0.004000
ap-southeast-2a t2.micro Linux/UNIX 0.004400
ap-southeast-2a t3.micro Linux/UNIX 0.004000
ap-southeast-2a t3.micro Linux/UNIX 0.004000
ap-southeast-2a t2.micro Linux/UNIX 0.004400
ap-southeast-2b t2.micro Linux/UNIX 0.004400
ap-southeast-2b t3.micro Linux/UNIX 0.004000
ap-southeast-2b t3.micro Linux/UNIX 0.004000
ap-southeast-2b t2.micro Linux/UNIX 0.004400
ap-southeast-2c t2.micro Linux/UNIX 0.004400
ap-southeast-2c t3.micro Linux/UNIX 0.004000
ap-southeast-2c t3.micro Linux/UNIX 0.004000
ap-southeast-2c t2.micro Linux/UNIX 0.004400
ca-central-1a t3.micro Linux/UNIX 0.003500
ca-central-1a t2.micro Linux/UNIX 0.003800
ca-central-1a t2.micro Linux/UNIX 0.003800
ca-central-1a t3.micro Linux/UNIX 0.003500
ca-central-1b t3.micro Linux/UNIX 0.003500
ca-central-1b t2.micro Linux/UNIX 0.003800
ca-central-1b t2.micro Linux/UNIX 0.003800
ca-central-1b t3.micro Linux/UNIX 0.003500
ca-central-1d t3.micro Linux/UNIX 0.003500
ca-central-1d t3.micro Linux/UNIX 0.003500
eu-central-1a t2.micro Linux/UNIX 0.004000
eu-central-1a t3.micro Linux/UNIX 0.003900
eu-central-1a t2.micro Linux/UNIX 0.004000
eu-central-1a t3.micro Linux/UNIX 0.003900
eu-central-1b t2.micro Linux/UNIX 0.004000
eu-central-1b t3.micro Linux/UNIX 0.003800
eu-central-1b t2.micro Linux/UNIX 0.004000
eu-central-1b t3.micro Linux/UNIX 0.003800
eu-central-1c t2.micro Linux/UNIX 0.004000
eu-central-1c t3.micro Linux/UNIX 0.003900
eu-central-1c t2.micro Linux/UNIX 0.004000
eu-central-1c t3.micro Linux/UNIX 0.003900
eu-north-1a t3.micro Linux/UNIX 0.003200
eu-north-1a t3.micro Linux/UNIX 0.003200
eu-north-1a t3.micro Linux/UNIX 0.003200
eu-north-1b t3.micro Linux/UNIX 0.003200
eu-north-1b t3.micro Linux/UNIX 0.003200
eu-north-1b t3.micro Linux/UNIX 0.003200
eu-north-1c t3.micro Linux/UNIX 0.003200
eu-north-1c t3.micro Linux/UNIX 0.003200
eu-north-1c t3.micro Linux/UNIX 0.003200
eu-west-1a t2.micro Linux/UNIX 0.003800
eu-west-1a t3.micro Linux/UNIX 0.003400
eu-west-1a t2.micro Linux/UNIX 0.003800
eu-west-1a t3.micro Linux/UNIX 0.003400
eu-west-1b t2.micro Linux/UNIX 0.003800
eu-west-1b t3.micro Linux/UNIX 0.003400
eu-west-1b t2.micro Linux/UNIX 0.003800
eu-west-1b t3.micro Linux/UNIX 0.003400
eu-west-1c t2.micro Linux/UNIX 0.003800
eu-west-1c t3.micro Linux/UNIX 0.003400
eu-west-1c t2.micro Linux/UNIX 0.003800
eu-west-1c t3.micro Linux/UNIX 0.003400
eu-west-2a t2.micro Linux/UNIX 0.004000
eu-west-2a t3.micro Linux/UNIX 0.003500
eu-west-2a t2.micro Linux/UNIX 0.004000
eu-west-2a t3.micro Linux/UNIX 0.003500
eu-west-2b t2.micro Linux/UNIX 0.004000
eu-west-2b t3.micro Linux/UNIX 0.003500
eu-west-2b t2.micro Linux/UNIX 0.004000
eu-west-2b t3.micro Linux/UNIX 0.003500
eu-west-2c t2.micro Linux/UNIX 0.004000
eu-west-2c t3.micro Linux/UNIX 0.003500
eu-west-2c t2.micro Linux/UNIX 0.004000
eu-west-2c t3.micro Linux/UNIX 0.003500
eu-west-3a t2.micro Linux/UNIX 0.004000
eu-west-3a t3.micro Linux/UNIX 0.003500
eu-west-3a t2.micro Linux/UNIX 0.004000
eu-west-3a t3.micro Linux/UNIX 0.003500
eu-west-3b t3.micro Linux/UNIX 0.003600
eu-west-3b t2.micro Linux/UNIX 0.004000
eu-west-3b t3.micro Linux/UNIX 0.003500
eu-west-3b t2.micro Linux/UNIX 0.004000
eu-west-3b t3.micro Linux/UNIX 0.003500
eu-west-3c t2.micro Linux/UNIX 0.004000
eu-west-3c t3.micro Linux/UNIX 0.003500
eu-west-3c t2.micro Linux/UNIX 0.004000
eu-west-3c t3.micro Linux/UNIX 0.003500
sa-east-1a t3.micro Linux/UNIX 0.005000
sa-east-1a t2.micro Linux/UNIX 0.005600
sa-east-1a t2.micro Linux/UNIX 0.005600
sa-east-1a t3.micro Linux/UNIX 0.005000
sa-east-1a t2.micro Linux/UNIX 0.005600
sa-east-1b t3.micro Linux/UNIX 0.016800
sa-east-1c t3.micro Linux/UNIX 0.005000
sa-east-1c t2.micro Linux/UNIX 0.005600
sa-east-1c t2.micro Linux/UNIX 0.005600
sa-east-1c t3.micro Linux/UNIX 0.005000
sa-east-1c t2.micro Linux/UNIX 0.005600
us-east-1a t2.micro Linux/UNIX 0.003500
us-east-1a t3.micro Linux/UNIX 0.003100
us-east-1a t2.micro Linux/UNIX 0.003500
us-east-1a t3.micro Linux/UNIX 0.003100
us-east-1b t2.micro Linux/UNIX 0.003500
us-east-1b t3.micro Linux/UNIX 0.003100
us-east-1b t2.micro Linux/UNIX 0.003500
us-east-1b t3.micro Linux/UNIX 0.003100
us-east-1c t2.micro Linux/UNIX 0.003500
us-east-1c t3.micro Linux/UNIX 0.003100
us-east-1c t2.micro Linux/UNIX 0.003500
us-east-1c t3.micro Linux/UNIX 0.003100
us-east-1d t2.micro Linux/UNIX 0.003500
us-east-1d t3.micro Linux/UNIX 0.003100
us-east-1d t2.micro Linux/UNIX 0.003500
us-east-1d t3.micro Linux/UNIX 0.003100
us-east-1e t2.micro Linux/UNIX 0.003500
us-east-1e t2.micro Linux/UNIX 0.003500
us-east-1f t2.micro Linux/UNIX 0.003500
us-east-1f t3.micro Linux/UNIX 0.003100
us-east-1f t2.micro Linux/UNIX 0.003500
us-east-1f t3.micro Linux/UNIX 0.003100
us-east-2a t3.micro Linux/UNIX 0.003100
us-east-2a t2.micro Linux/UNIX 0.003500
us-east-2a t3.micro Linux/UNIX 0.003100
us-east-2a t2.micro Linux/UNIX 0.003500
us-east-2b t2.micro Linux/UNIX 0.003500
us-east-2b t3.micro Linux/UNIX 0.003100
us-east-2b t2.micro Linux/UNIX 0.003500
us-east-2b t3.micro Linux/UNIX 0.003100
us-east-2c t2.micro Linux/UNIX 0.003500
us-east-2c t3.micro Linux/UNIX 0.003100
us-east-2c t2.micro Linux/UNIX 0.003500
us-east-2c t3.micro Linux/UNIX 0.003100
us-west-1a t2.micro Linux/UNIX 0.004100
us-west-1a t3.micro Linux/UNIX 0.003700
us-west-1a t3.micro Linux/UNIX 0.003700
us-west-1a t2.micro Linux/UNIX 0.004100
us-west-1a t3.micro Linux/UNIX 0.003700
us-west-1b t2.micro Linux/UNIX 0.004100
us-west-1b t3.micro Linux/UNIX 0.003700
us-west-1b t3.micro Linux/UNIX 0.003700
us-west-1b t2.micro Linux/UNIX 0.004100
us-west-1b t3.micro Linux/UNIX 0.003700
us-west-2a t3.micro Linux/UNIX 0.003100
us-west-2a t2.micro Linux/UNIX 0.003500
us-west-2a t3.micro Linux/UNIX 0.003100
us-west-2a t2.micro Linux/UNIX 0.003500
us-west-2b t3.micro Linux/UNIX 0.003100
us-west-2b t2.micro Linux/UNIX 0.003500
us-west-2b t3.micro Linux/UNIX 0.003100
us-west-2b t2.micro Linux/UNIX 0.003500
us-west-2c t3.micro Linux/UNIX 0.003100
us-west-2c t2.micro Linux/UNIX 0.003500
us-west-2c t3.micro Linux/UNIX 0.003100
us-west-2c t2.micro Linux/UNIX 0.003500
us-west-2d t3.micro Linux/UNIX 0.003100
us-west-2d t3.micro Linux/UNIX 0.003100
■インスタンスタイプと価格ごとに、AZをリスト化。
※価格の安い順でソート
$ awk '{a[$2"_"$NF]=a[$2"_"$NF]";"$1}END{for(n in a){print n,a[n] | "sort -uV -t _ -k 2"}}' tn.micro-pricelist | sed -e 's/_/ /g' -e 's/;/\n\t/g'
t3.micro 0.003100
us-east-1a
us-east-1a
us-east-1b
us-east-1b
us-east-1c
us-east-1c
us-east-1d
us-east-1d
us-east-1f
us-east-1f
us-east-2a
us-east-2a
us-east-2b
us-east-2b
us-east-2c
us-east-2c
us-west-2a
us-west-2a
us-west-2b
us-west-2b
us-west-2c
us-west-2c
us-west-2d
us-west-2d
t3.micro 0.003200
eu-north-1a
eu-north-1a
eu-north-1a
eu-north-1b
eu-north-1b
eu-north-1b
eu-north-1c
eu-north-1c
eu-north-1c
t3.micro 0.003400
ap-south-1a
ap-south-1a
ap-south-1b
ap-south-1b
ap-south-1c
ap-south-1c
eu-west-1a
eu-west-1a
eu-west-1b
eu-west-1b
eu-west-1c
eu-west-1c
t3.micro 0.003500
ca-central-1a
ca-central-1a
ca-central-1b
ca-central-1b
ca-central-1d
ca-central-1d
eu-west-2a
eu-west-2a
eu-west-2b
eu-west-2b
eu-west-2c
eu-west-2c
eu-west-3a
eu-west-3a
eu-west-3b
eu-west-3b
eu-west-3c
eu-west-3c
t2.micro 0.003500
us-east-1a
us-east-1a
us-east-1b
us-east-1b
us-east-1c
us-east-1c
us-east-1d
us-east-1d
us-east-1e
us-east-1e
us-east-1f
us-east-1f
us-east-2a
us-east-2a
us-east-2b
us-east-2b
us-east-2c
us-east-2c
us-west-2a
us-west-2a
us-west-2b
us-west-2b
us-west-2c
us-west-2c
t3.micro 0.003600
eu-west-3b
t2.micro 0.003700
ap-south-1a
ap-south-1a
ap-south-1a
ap-south-1a
ap-south-1b
ap-south-1b
ap-south-1b
ap-south-1b
t3.micro 0.003700
us-west-1a
us-west-1a
us-west-1a
us-west-1b
us-west-1b
us-west-1b
t2.micro 0.003800
ca-central-1a
ca-central-1a
ca-central-1b
ca-central-1b
eu-west-1a
eu-west-1a
eu-west-1b
eu-west-1b
eu-west-1c
eu-west-1c
t3.micro 0.003800
eu-central-1b
eu-central-1b
t3.micro 0.003900
ap-northeast-2a
ap-northeast-2a
ap-northeast-2b
ap-northeast-2b
ap-northeast-2c
ap-northeast-2c
ap-northeast-2d
ap-northeast-2d
eu-central-1a
eu-central-1a
eu-central-1c
eu-central-1c
t3.micro 0.004000
ap-southeast-1b
ap-southeast-1b
ap-southeast-1c
ap-southeast-1c
ap-southeast-2a
ap-southeast-2a
ap-southeast-2b
ap-southeast-2b
ap-southeast-2c
ap-southeast-2c
t2.micro 0.004000
eu-central-1a
eu-central-1a
eu-central-1b
eu-central-1b
eu-central-1c
eu-central-1c
eu-west-2a
eu-west-2a
eu-west-2b
eu-west-2b
eu-west-2c
eu-west-2c
eu-west-3a
eu-west-3a
eu-west-3b
eu-west-3b
eu-west-3c
eu-west-3c
t3.micro 0.004100
ap-northeast-1a
ap-northeast-1a
ap-northeast-1c
ap-northeast-1c
ap-northeast-1d
ap-northeast-1d
ap-northeast-3a
ap-northeast-3a
ap-northeast-3a
ap-northeast-3b
ap-northeast-3b
ap-northeast-3b
ap-northeast-3c
ap-northeast-3c
ap-northeast-3c
t2.micro 0.004100
us-west-1a
us-west-1a
us-west-1b
us-west-1b
t2.micro 0.004300
ap-northeast-2a
ap-northeast-2a
ap-northeast-2c
ap-northeast-2c
t2.micro 0.004400
ap-southeast-1a
ap-southeast-1a
ap-southeast-1b
ap-southeast-1b
ap-southeast-1c
ap-southeast-1c
ap-southeast-2a
ap-southeast-2a
ap-southeast-2b
ap-southeast-2b
ap-southeast-2c
ap-southeast-2c
t3.micro 0.004500
ap-southeast-1a
t2.micro 0.004600
ap-northeast-1a
ap-northeast-1a
ap-northeast-1c
ap-northeast-1c
ap-northeast-1d
ap-northeast-1d
ap-northeast-3a
ap-northeast-3a
t3.micro 0.004600
ap-southeast-1a
t3.micro 0.005000
sa-east-1a
sa-east-1a
sa-east-1c
sa-east-1c
t2.micro 0.005600
sa-east-1a
sa-east-1a
sa-east-1a
sa-east-1c
sa-east-1c
sa-east-1c
t3.micro 0.016800
sa-east-1b
■AZ、us-east-1aのt3.microの料金は過去三ヶ月変更なし。
$ echo us-east-1a | awk '{print " sed -i -e \047s/region = .*/region = "substr($1,1,length($1)-1)"/\047 ~/.aws/config;" \
" aws ec2 describe-spot-price-history" \
" --availability-zone "$1 \
" --start-time $(date -d \0473 month ago\047 -u \047+%Y-%m-%dT%H:%M:%S.000Z\047)" \
" --product-description \042Linux/UNIX\042" \
" --instance-types \042t3.micro\042" \
" --query \047SpotPriceHistory[].{InstanceType:InstanceType," \
"ProductDescription:ProductDescription,AvailabilityZone:AvailabilityZone,SpotPrice:SpotPrice}\047" \
" --output text"}'| sh | sort | uniq -c
93 us-east-1a t3.micro Linux/UNIX 0.003100
■リージョン書き換えを戻す。
$ mv .aws/config{-back,}