Home > Blockchain >  aws cli - How to query only ec2 on demand instances
aws cli - How to query only ec2 on demand instances

Time:10-03

aws ec2 describe-instances --filters Name=tag-key,Values=Name --query 'Reservations[*].Instances[*].{Instance:InstanceId,Name:Tags[?Key==`Name`]|[0].Value,}' --output table

I've tried using this query but I don't know how to show only the on demand, or at least list it aside..

CodePudding user response:

Unfortunately, there is no way to know if an instance is on-demand or even reserved using the describe-instances endpoint.

The most you can get is knowing if the instance is a spot instance or not, by checking to see if the spot-instance-request-id is populated.

Reference: describe-instances

CodePudding user response:

As far as I know, there is no way to learn it, only instance types (ex: t2.micro) are available.

The documentation says supported-usage-class filters you the usage class though.

  • Related