Describe AWS EC2 instances

Given an instance-id alone:

aws ec2 describe-instances --instance-ids i-001fa90ce5949539f i-0ffbee16785c3cab4

With filters:

aws ec2 describe-instances \
    --filters "Name=instance-type,Values=m5d.metal" "Name=instance-state-name,Values=running" "Name=image-id,Values=ami-foo" \
    --no-paginate \

Other filters:

  • "Name=instance-id,Values=i-0bf18c34a79da1027"

Can also add the following:

  • | jq -r ".Reservations|.[]|.Instances|.[]|.PublicIpAddress"
  • | jq -r ".Reservations|.[]|.Instances|.[]|.Placement.AvailabilityZone"

Resources: