The EC2 Spot advisor which is available in the url - https://us-west-2.console.aws.amazon.com/ec2sp/v1/spot/advisor?region=us-west-2 provides recommendation on which instance-type in an availability zone has the least likelihood of getting intervened(Terminated) and the spot price.
Is there a programmable way(api/sdk, etc) to get this data from a script to automate provisioning instances using this data?
I am having the same issue, I noticed in the network tab that the data is coming from an API get_advice, but I cannot find that API anywhere in the AWS SDK/CLI docs.
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
It returns machine-parseable JSON data like this:
[
  {
    "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
  }
]
This could be used to populate LaunchSpecifications in request-spot-fleet, however the API is probably not stable, and needs a console authentication token.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With