get ec2 pricing programmatically?

后端 未结 11 571
借酒劲吻你
借酒劲吻你 2020-11-30 18:22

Is there a way to get AWS pricing programmatically (cost per hour of each instance type, cost per GB/month of storage on S3, and etc)?

Also, are there cost monitorin

11条回答
  •  失恋的感觉
    2020-11-30 19:04

    In addition to @arturhoo's answer which provides the EC2 spots

    You can obtain the historic prices with the CLI tool

    aws ec2 describe-spot-price-history \
        --instance-types m1.xlarge \
        --product-description "Linux/UNIX (Amazon VPC)" \
        --start-time 2016-10-31T03:00:00 \
        --end-time 2016-10-31T03:16:00 \
        --query 'SpotPriceHistory[*].[Timestamp,SpotPrice]'
    

    which takes the spot price between 3:00am and 3:16am Monday 31st October 2016 (UTC)

    [
        [
            "2016-10-31T03:06:12.000Z", 
            "0.041500"
        ], 
        [
            "2016-10-31T03:00:26.000Z", 
            "0.041600"
        ], 
        [
            "2016-10-31T02:59:14.000Z", 
            "0.041500"
        ], 
        [
            "2016-10-31T02:00:18.000Z", 
            "0.040600"
        ], 
        [
            "2016-10-30T23:55:06.000Z", 
            "0.043200"
        ]
    ]
    

提交回复
热议问题