Alex Cohen
Alex Cohen

Reputation: 6196

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

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?

Upvotes: 0

Views: 1470

Answers (2)

Peter Han
Peter Han

Reputation: 547

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.

Upvotes: 0

jamesls
jamesls

Reputation: 5608

You can use the --query arg for this:

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

Upvotes: 1

Related Questions