简体   繁体   中英

aws cli - How to query only ec2 on demand instances

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..

this query will give you non-spot instances:

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

If you just want the InstanceLifecycle value to appear in your output results, add it to --query :

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM