Skip to content

Instantly share code, notes, and snippets.

@jftuga
Created August 3, 2020 21:49
Show Gist options
  • Save jftuga/18abbec82dfc1b89c97ff55b782e2c5f to your computer and use it in GitHub Desktop.
Save jftuga/18abbec82dfc1b89c97ff55b782e2c5f to your computer and use it in GitHub Desktop.
#!/bin/bash
# ec2info.sh
# -John Taylor
# Aug-03-2020
# Retrieve EC2 instance type info such as vCPU, clock speed, memory, network
# This queries your default AWS region
# Results are saved to the user-defined file name: $TSV and also to the MacOS clipboard
# Note: the 'RAM in GB' column is rounded to the nearest whole number
#
# You should use aws cli version 2
# This was created with:
# aws-cli/2.0.36
#
# You must have 'jq' installed from:
# https://stedolan.github.io/jq/
TSV=results.TSV
JSON=page.json
JQ='.InstanceTypes | .[] | [ .InstanceType,.VCpuInfo.DefaultVCpus,.ProcessorInfo.SustainedClockSpeedInGhz,((.MemoryInfo.SizeInMiB/1024)|round),.NetworkInfo.NetworkPerformance ] | @tsv'
aws ec2 describe-instance-types >> ${JSON}
printf "InstanceType\tvCPU Count\tSustained Clock Speed\tRAM in GB\tNetwork Performance \n" > ${TSV}
jq -r "${JQ}" ${JSON} >> ${TSV}
pbcopy < ${TSV}
rm ${JSON}
echo
echo Saved $(wc -l ${TSV}|awk '{print $1}') results to the tab-separated file: ${TSV}
echo and also copied to the MacOS clipboard
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment