Skip to content

Instantly share code, notes, and snippets.

@giseongeom
Last active August 4, 2020 06:27
Show Gist options
  • Save giseongeom/a94eeba8f9d522fab7592786740b9331 to your computer and use it in GitHub Desktop.
Save giseongeom/a94eeba8f9d522fab7592786740b9331 to your computer and use it in GitHub Desktop.
Retrieve AWS EC2 instance types (Scope: region)
#Requires -version 5.1
Param ([string]$region = 'ap-northeast-2')
Import-Module AWS.Tools.Common
Import-Module aws.tools.ec2
Param ([string]$region = 'ap-northeast-2')
Set-AWSCredential -ProfileName default
Set-DefaultAWSRegion -Region $region
Write-Host -NoNewline '01: Region: '
Write-Host $region
$ec2_offer = Get-EC2InstanceTypeOffering -LocationType availability-zone | Sort-Object InstanceType
Write-Host -NoNewline '02: Exporting to ec2-list.csv: '
$ec2_offer |
Select-Object InstanceType,Location |
export-CSV ec2-list.csv -ErrorAction SilentlyContinue -Force
if ($?) { Write-Host 'Done.'}
Write-Host '03: Instance types per availability-zone '
$ec2_offer | Sort-Object location,InstanceType | ft -GroupBy location
@giseongeom
Copy link
Author

giseongeom commented Aug 4, 2020

  • 테스트
  • 기본 리젼: ap-northeast-2
PS > .\get-EC2TypeList.ps1 -region ap-northeast-1

01: Region: ap-northeast-1
02: Exporting to ec2-list.csv: Done.
03: Instance types per availability-zone  

   Location: ap-northeast-1a

InstanceType  Location        LocationType     
------------  --------        ------------     
a1.2xlarge    ap-northeast-1a availability-zone
a1.4xlarge    ap-northeast-1a availability-zone
a1.large      ap-northeast-1a availability-zone
a1.medium     ap-northeast-1a availability-zone

.... 생략 ....


   Location: ap-northeast-1d

InstanceType  Location        LocationType     
------------  --------        ------------     
a1.2xlarge    ap-northeast-1d availability-zone
a1.4xlarge    ap-northeast-1d availability-zone
a1.large      ap-northeast-1d availability-zone

.... 생략 ....

z1d.6xlarge   ap-northeast-1d availability-zone
z1d.large     ap-northeast-1d availability-zone
z1d.metal     ap-northeast-1d availability-zone
z1d.xlarge    ap-northeast-1d availability-zone


PS > gc .\ec2-list.csv -TotalCount 10
#TYPE Selected.Amazon.EC2.Model.InstanceTypeOffering
"InstanceType","Location"
"a1.2xlarge","ap-northeast-1a"
"a1.2xlarge","ap-northeast-1d"
"a1.4xlarge","ap-northeast-1a"
"a1.4xlarge","ap-northeast-1d"
"a1.large","ap-northeast-1d"
"a1.large","ap-northeast-1a"
"a1.medium","ap-northeast-1a"
"a1.medium","ap-northeast-1d"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment