Skip to content

Instantly share code, notes, and snippets.

@jweyrich
Last active August 28, 2021 05:19
Show Gist options
  • Save jweyrich/e134c92b7045c6322845bb37e7ea7a15 to your computer and use it in GitHub Desktop.
Save jweyrich/e134c92b7045c6322845bb37e7ea7a15 to your computer and use it in GitHub Desktop.
List instances attributes using AWS CLI and JQ
#!/bin/bash
PROFILE=default
REGION=us-east-1
aws --profile=$PROFILE --region=$REGION --output=text ec2 describe-instances \
--query "Reservations[*].Instances[*].[InstanceType, State.Name, Platform, Tags[?Key=='Name']]"
aws --profile=$PROFILE --region=$REGION --output=json ec2 describe-instances \
| jq '.Reservations[].Instances[] | "\(.InstanceType); \(.State.Name); \(.Platform); \(.Tags[]//[]|select(.Key=="Name")|.Value)"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment