Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There's a AWS metadata service which provides some information about the EC2 instance that issues a request to I'm wondering if there's a way to know from that metadata if the instance is "Spot" or "On Demand"?

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
Nice! Thanks, I've been looking for this for a while and must have overlooked it when looking at the instance data. – SaxDaddy Dec 26 '15 at 9:32

I don't believe they have this information in the metadata.

You could assign a different profile for instances you launch as spot instances and use the profile name to determine what type of instance it is. If that doesn't seem like a clean or viable solution you can always grab the instance-id from the meta data then run the command ec2-describe-spot-instance-requests --filter instance-id=<instanceid> if the command returns empty than the instance is not a spot instance, if the command returns with data then it's a spot instance.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.