I begin to use
Amazon EC2 Spot Instances and feel like knowing the maximum and minimum price from the spot price history with a combination of AWS CLI and
jq.
The sample below is supposed that Instance type is m1.small and Availability Zone is ap-northeast-1a in Tokyo region.
* Describe the maximum price
$ instance_type=m1.small
$ aws ec2 describe-spot-price-history \
--instance-types ${instance_type} \
--product-descriptions Linux/UNIX \(Amazon VPC\) \
--availability-zone ap-northeast-1a | jq ' .[] | max_by(.SpotPrice)'
{
"AvailabilityZone": "ap-northeast-1a",
"SpotPrice": "0.352000",
"InstanceType": "m1.small",
"ProductDescription": "Linux/UNIX",
"Timestamp": "2014-02-01T05:01:34.000Z"
}
* Describe the minimum price
$ instance_type=m1.small
$ aws ec2 describe-spot-price-history \
--instance-types ${instance_type} \
--product-descriptions Linux/UNIX \(Amazon VPC\) \
--availability-zone ap-northeast-1a | jq ' .[] | min_by(.SpotPrice)'
{
"AvailabilityZone": "ap-northeast-1a",
"SpotPrice": "0.017100",
"InstanceType": "m1.small",
"ProductDescription": "Linux/UNIX",
"Timestamp": "2014-04-01T09:35:08.000Z"
}
I tried, but I am not sure if it's possible to output both maximum and minimum in one line.
No comments:
Post a Comment