From Public wiki of Kevin P. Inscoe
Jump to navigation Jump to search

More on AWS CLI at

In many of these examples you will need command line tool jq installed. See

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'