Skip to content

Instantly share code, notes, and snippets.

@saswata-dutta
Last active September 10, 2019 14:30
Show Gist options
  • Select an option

  • Save saswata-dutta/7487eda2007e2d0146f23959204611f0 to your computer and use it in GitHub Desktop.

Select an option

Save saswata-dutta/7487eda2007e2d0146f23959204611f0 to your computer and use it in GitHub Desktop.
aws ec2 describe-instances \
--filters "Name=tag:Business_Vertical,Values=DS,ds" "Name=instance-state-code,Values=16" \
--query 'Reservations[].Instances[].{ name : Tags[?Key==`Name`].Value | [0], type : InstanceType }' \
--no-paginate --output=json --region ap-southeast-1 | \
jq 'group_by(.name) | map({ (.[0].name) : ([.[].type]) })'
aws ec2 describe-instances \
--filters "Name=tag:Business_Vertical,Values=DS,ds" "Name=instance-state-code,Values=16" \
--query 'Reservations[].Instances[].{ name : Tags[?Key==`Name`].Value | [0], size : InstanceType, type: InstanceLifecycle, owner: Tags[?Key==`Owner`].Value | [0] }' \
--no-paginate --output=table
aws ec2 describe-instances \
--filters "Name=tag:Business_Vertical,Values=DS,ds" "Name=instance-state-code,Values=16" \
--query 'Reservations[].Instances[].{ owner : Tags[?Key==`Owner`].Value | [0], name : Tags[?Key==`Name`].Value | [0], type : InstanceType }' \
--no-paginate --output=json --region ap-southeast-1 | \
jq 'group_by(.owner) | map({ (.[0].owner) : (map({name : .name, type: .type}) | group_by(.name) | map({ (.[0].name) : ([.[].type]) }) ) })'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment