url - https://us-west-2.console.aws.amazon.com/ec2sp/v1/spot/advisor?region=us-west-2中提供的EC2 Spot advisor提供了关于可用区中哪种实例类型被干预(终止)的可能性最小的建议和现货价格。
有没有一种可编程的方式(api/sdk等)来从脚本中获取这些数据,以便使用这些数据自动配置实例?
发布于 2019-01-31 13:46:36
我也遇到了同样的问题,我注意到网络选项卡中的数据来自API,但我在AWS SDK/ get_advice
文档中找不到该API。
GET https://us-west-2.console.aws.amazon.com/ec2sp/services/get_advice?product=linux&cheapest=90&min_cpu=2&min_ram=3&same_size=false¶llelability=90&az=any
它返回机器可解析的JSON数据,如下所示:
[
{
"instanceType": "t2.medium",
"azs": [
"us-west-2a",
"us-west-2b",
"us-west-2c"
],
"averagePrice": 0.0139,
"pricePerUnit": 0.0139,
"downtime": null,
"terminationProbability": 0,
"averageQuality": 0.01251
},
{
"instanceType": "t3.2xlarge",
"azs": [
"us-west-2a",
"us-west-2b",
"us-west-2c"
],
"averagePrice": 0.1002,
"pricePerUnit": 0.0251,
"downtime": null,
"terminationProbability": 0,
"averageQuality": 0.024372972972972973
},
{
"instanceType": "t2.large",
"azs": [
"us-west-2a",
"us-west-2b"
],
"averagePrice": 0.0278,
"pricePerUnit": 0.0278,
"downtime": null,
"terminationProbability": 0,
"averageQuality": 0.02502
}
]
这可以用来填充request-spot-fleet中的LaunchSpecifications
,但是API可能并不稳定,需要一个控制台身份验证令牌。
https://stackoverflow.com/questions/50008464
复制