Undefined Title

Undefined Title

Filtering instance IDs of aws ec2 with jq

How to list all stopped (or running) instances with aws-cli and filter only instance id using jq.

$ aws ec2 describe-instances \
  --filter Name=instance-state-name,Values=stopped \
  | jq ".[][].Instances[].InstanceId" -r
i-092fxxxx
i-91ffxxxx
i-9f63xxxx
i-8872xxxx
i-fac6xxxx

jq is really very useful.