Skip to content

Instantly share code, notes, and snippets.

@sharuzzaman
Last active May 19, 2020 09:23
Show Gist options
  • Save sharuzzaman/af3131a874ab4262a825d0ae0173954b to your computer and use it in GitHub Desktop.
Save sharuzzaman/af3131a874ab4262a825d0ae0173954b to your computer and use it in GitHub Desktop.
Get a list of devices for each running EC2 instances sorted by name
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" | jq '[.Reservations[]|.Instances[]|{Name: .Tags[]|select(.Key == "Name").Value,DeviceName: [.BlockDeviceMappings[]|.DeviceName]}]|sort_by(.Name)' ec2.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment