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.