AWS CLI Hacks: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
More on AWS CLI at https://aws.amazon.com/cli/ | More on AWS CLI at https://aws.amazon.com/cli/ | ||
In many of these examples you will need command line tool jq installed. See https://stedolan.github.io/jq/ | |||
Generally for Mac: $ brew install jq | |||
==EC2 Inventory== | ==EC2 Inventory== |
Latest revision as of 20:07, 13 April 2020
More on AWS CLI at https://aws.amazon.com/cli/
In many of these examples you will need command line tool jq installed. See https://stedolan.github.io/jq/
Generally for Mac: $ brew install jq
EC2 Inventory
# Print instance id, name tag (if set) and instance state by name in CSV format $ aws cli <profile-name> --output json --region us-east-1 ec2 describe-instances | \ jq -r '.Reservations[].Instances[] | (.Tags | from_entries) as $tags | [.InstanceId, $tags.Name?, .State.Name] | @csv' "i-0191a4dge87a52360","instance-b","stopped" "i-1234567890abcdef0","instance-a","running"