AWS ec2 describe-instance-status only for instances with events

为君一笑 提交于 2019-12-25 07:26:37

问题


Is there a easy way to run aws ec2 describe-instance-status and only display the information of instances if they have any Scheduled Events?


回答1:


You can use the --query arg for this:

$ aws ec2 describe-instance-status --query 'InstanceStatuses[?length(Events || `[]`) > `0`]'



回答2:


Or you can use --filter CLI argument for this:

$ aws ec2 describe-instance-status --filters "Name=event.code,Values='instance-reboot','system-reboot','system-maintenance','instance-retirement','instance-stop'"

This filters statuses only down to the ones with events with the specified code. Since this command lists out all possible codes, you basically get only the statuses with one or more events.



来源:https://stackoverflow.com/questions/39300976/aws-ec2-describe-instance-status-only-for-instances-with-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!