Last active
July 19, 2020 14:03
-
-
Save jftuga/b5a4db00f8de73a501331f7b1c0b7332 to your computer and use it in GitHub Desktop.
ec2info: retrieve all EC2 instance type info such as vCPU, clock speed, memory, network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
rem ec2info.bat | |
rem -John Taylor | |
rem Jul-19-2020 | |
rem Retrieve all EC2 instance type info such as vCPU, clock speed, memory, network | |
rem Save results to a tab separated file, named 'ec2_types.tsv' | |
rem Note: the 'RAM in GB' column is rounded to the nearest whole number | |
rem | |
rem You must have 'jq' installed from: | |
rem https://stedolan.github.io/jq/ | |
set TSV=ec2_types.tsv | |
set JSON=page.json | |
set NEXT=token.tmp | |
set JQ=".InstanceTypes | .[] | [ .InstanceType,.VCpuInfo.DefaultVCpus,.ProcessorInfo.SustainedClockSpeedInGhz,((.MemoryInfo.SizeInMiB/1024)|round),.NetworkInfo.NetworkPerformance ] | @tsv" | |
:FIRST | |
aws ec2 describe-instance-types > %JSON% | |
jq -r %JQ% %JSON% > %TSV% | |
jq -r ".NextToken" %JSON% > %NEXT% | |
set /p TOK=<%NEXT% | |
:LOOP | |
if "%TOK%"=="null" goto END | |
aws ec2 describe-instance-types --next-token "%TOK%" > %JSON% | |
jq -r %JQ% %JSON% >> %TSV% | |
jq -r ".NextToken" %JSON% > %NEXT% | |
set /p TOK=<%NEXT% | |
goto LOOP | |
:END | |
del %JSON% %NEXT% | |
@echo. | |
@echo Wrote output to: %TSV% | |
@echo Tab-separated columns: | |
@echo vCPU Count, Sustained Clock Speed, RAM in GB, Network Performance | |
@echo. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment