Skip to content

Instantly share code, notes, and snippets.

@urjitbhatia
Created May 3, 2019 18:52
Show Gist options
  • Save urjitbhatia/c5af8a3d53661cb3d4e896feae23fc1d to your computer and use it in GitHub Desktop.
Save urjitbhatia/c5af8a3d53661cb3d4e896feae23fc1d to your computer and use it in GitHub Desktop.
Check if an ec2 instance is spot or normal lifecycle
#!/bin/bash
aws ec2 describe-spot-instance-requests \
--filters Name=instance-id,Values="$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)" \
--region us-east-1 | \
jq -r '.SpotInstanceRequests | if length > 0 then "spot" else "normal" end'
@ppi-agray
Copy link

@urjitbhatia , Thank you so much for this code snippet. It was exactly what I was looking for!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment