There's a AWS metadata service which provides some information about the EC2 instance that issues a request to http://169.254.169.254/
. I'm wondering if there's a way to know from that metadata if the instance is "Spot" or "On Demand"?
AWS metadata: Check if EC2 instance is spot
amazon ec2amazon-web-services
Best Answer
The information is not available inside the metadata.
However, you can get the instance ID from the metadata, then call ec2-describe-instances to get instance information about your instance. Inside that instance description is the spot instance request ID. If blank, then it's not a spot instance, otherwise, it's a spot instance.