There are over 800 different instance types available on EC2 which can make the process of selecting appropriate instance types difficult. Instance Selector helps you select compatible instance types for your application to run on. The command line interface can be passed resource criteria like vcpus, memory, network performance, and much more and then return the available, matching instance types.
If you are using spot instances to save on costs, it is a best practice to use multiple instances types within your auto-scaling group (ASG) to ensure your application doesn't experience downtime due to one instance type being interrupted. Instance Selector will help to find a set of instance types that your application can run on.
Instance Selector can also be consumed as a go library for direct integration into your go code.
--base-instance-type and --flexible--output interactivebrew tap aws/tap
brew install ec2-instance-selector
os=$(uname | tr 'A-Z' 'a-z')
arch=$(printf "%s" "$(uname -m | tr 'A-Z' 'a-z' | sed -E 's/x86_64|i[3-6]86/amd64/;s/aarch64|arm64/arm64/')")
curl -Lo ec2-instance-selector https://github.com/aws/amazon-ec2-instance-selector/releases/latest/download/ec2-instance-selector-$os-$arch && chmod +x ec2-instance-selector
sudo mv ec2-instance-selector /usr/local/bin/
ec2-instance-selector --version
To execute the CLI, you will need AWS credentials configured. Take a look at the AWS CLI configuration documentation for details on the various ways to configure credentials. An easy way to try out the ec2-instance-selector CLI is to populate the following environment variables with your AWS API credentials.
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
If you already have an AWS CLI profile setup, you can pass that directly into ec2-instance-selector:
$ ec2-instance-selector --profile my-aws-cli-profile --vcpus 2 --region us-east-1
You can set the AWS_REGION environment variable if you don't want to pass in --region on each run.
$ export AWS_REGION="us-east-1"
Find Instance Types with 4 GiB of memory, 2 vcpus, and runs on the x86_64 CPU architecture
$ ec2-instance-selector --memory 4 --vcpus 2 --cpu-architecture x86_64 -r us-east-1
c5.large
c5a.large
c5ad.large
c5d.large
c6a.large
c6i.large
c6id.large
c6in.large
c7a.large
c7i-flex.large
c7i.large
t2.medium
t3.medium
t3a.medium
Find instance types that support 100GB/s networking that can be purchased as spot instances
$ ec2-instance-selector --network-performance 100 --usage-class spot -r us-east-1
c5n.18xlarge
c5n.metal
c6gn.16xlarge
c6in.16xlarge
c7gn.8xlarge
dl1.24xlarge
f2.48xlarge
g4dn.metal
g5.48xlarge
g6.48xlarge
g6e.12xlarge
i3en.24xlarge
i3en.metal
i7ie.24xlarge
i7ie.48xlarge
im4gn.16xlarge
inf1.24xlarge
inf2.48xlarge
m5dn.24xlarge
m5dn.metal
NOTE: 22 entries were truncated, increase --max-results to see more
Short Table Output
$ ec2-instance-selector --memory 4 --vcpus 2 --cpu-architecture x86_64 -r us-east-1 -o table
Instance Type VCPUs Mem (GiB)
------------- ----- ---------
c5.large 2 4
c5a.large 2 4
c5ad.large 2 4
c5d.large 2 4
c6a.large 2 4
c6i.large 2 4
c6id.large 2 4
c6in.large 2 4
c7a.large 2 4
c7i-flex.large 2 4
c7i.large 2 4
t2.medium 2 4
t3.medium 2 4
t3a.medium 2 4
Wide Table Output
$ ec2-instance-selector --memory 4 --vcpus 2 --cpu-architecture x86_64 -r us-east-1 -o table-wide
Instance Type VCPUs Mem (GiB) Hypervisor Current Gen Hibernation Support CPU Arch Network Performance ENIs GPUs GPU Mem (GiB) GPU Info On-Demand Price/Hr Spot Price/Hr
------------- ----- --------- ---------- ----------- ------------------- -------- ------------------- ---- ---- ------------- -------- ------------------ -------------
c5.large 2 4 nitro true true x86_64 Up to 10 Gigabit 3 0 0 none $0.085 $0.0264
c5a.large 2 4 nitro true false x86_64 Up to 10 Gigabit 3 0 0 none $0.077 $0.025
c5ad.large 2 4 nitro true false x86_64 Up to 10 Gigabit 3 0 0 none $0.086 $0.0358
c5d.large 2 4 nitro true true x86_64 Up to 10 Gigabit 3 0 0 none $0.096 $0.036
c6a.large 2 4 nitro true true x86_64 Up to 12.5 Gigabit 3 0 0 none $0.0765 $0.0252
c6i.large 2 4 nitro true true x86_64 Up to 12.5 Gigabit 3 0 0 none $0.085 $0.0252
c6id.large 2 4 nitro true true x86_64 Up to 12.5 Gigabit 3 0 0 none $0.1008 $0.0359
c6in.large 2 4 nitro true true x86_64 Up to 25 Gigabit 3 0 0 none $0.1134 $0.043
c7a.large 2 4 nitro true true x86_64 Up to 12.5 Gigabit 3 0 0 none $0.10264 $0.0429
c7i-flex.large 2 4 nitro true true x86_64 Up to 12.5 Gigabit 3 0 0 none $0.08479 $0.0245
c7i.large 2 4 nitro true true x86_64 Up to 12.5 Gigabit 3 0 0 none $0.08925 $0.0367
t2.medium 2 4 xen true true i386, x86_64 Low to Moderate 3 0 0 none $0.0464 $0.0135
t3.medium 2 4 nitro true true x86_64 Up to 5 Gigabit 3 0 0 none $0.0416 $0.016
t3a.medium 2 4 nitro true true x86_64 Up to 5 Gigabit 3 0 0 none $0.0376 $0.0108
Interactive Output
$ ec2-instance-selector -o interactive
https://user-images.githubusercontent.com/68402662/184218343-6b236d4a-3fe6-42ae-9fe3-3fd3ee92a4b5.mov
Sort by memory in ascending order using shorthand
$ ec2-instance-selector -r us-east-1 -o table-wide --max-results 10 --sort-by memory --sort-direction asc
Instance Type VCPUs Mem (GiB) Hypervisor Current Gen Hibernation Support CPU Arch Network Performance ENIs GPUs GPU Mem (GiB) GPU Info On-Demand Price/Hr Spot Price/Hr
------------- ----- --------- ---------- ----------- ------------------- -------- ------------------- ---- ---- ------------- -------- ------------------ -------------
t2.nano 1 0.5 xen true true i386, x86_64 Low to Moderate 2 0 0 none $0.0058 -Not Fetched-
t4g.nano 2 0.5 nitro true true arm64 Up to 5 Gigabit 2 0 0 none $0.0042 $0.0011
t3.nano 2 0.5 nitro true true x86_64 Up to 5 Gigabit 2 0 0 none $0.0052 $0.0011
t3a.nano 2 0.5 nitro true true x86_64 Up to 5 Gigabit 2 0 0 none $0.0047 $0.0022
t1.micro 1 0.6123 xen false false i386, x86_64 Very Low 2 0 0 none $0.02 $0.0024
t2.micro 1 1 xen true true i386, x86_64 Low to Moderate 2 0 0 none $0.0116 $0.0029
t3a.micro 2 1 nitro true true x86_64 Up to 5 Gigabit 2 0 0 none $0.0094 $0.0033
t4g.micro 2 1 nitro true true arm64 Up to 5 Gigabit 2 0 0 none $0.0084 $0.0046
t3.micro 2 1 nitro true true x86_64 Up to 5 Gigabit 2 0 0 none $0.0104 $0.0028
m1.small 1 1.69922 xen false false i386, x86_64 Low 2 0 0 none $0.044 $0.0115
NOTE: 855 entries were truncated, increase --max-results to see more
Available shorthand flags: vcpus, memory, gpu-memory-total, network-interfaces, spot-price, on-demand-price, instance-storage, ebs-optimized-baseline-bandwidth, ebs-optimized-baseline-throughput, ebs-optimized-baseline-iops, gpus, inference-accelerators
Sort by memory in descending order using JSON path
$ ec2-instance-selector -r us-east-1 -o table-wide --max-results 10 --sort-by .MemoryInfo.SizeInMiB --sort-direction desc
Instance Type VCPUs Mem (GiB) Hypervisor Current Gen Hibernation Support CPU Arch Network Performance ENIs GPUs GPU Mem (GiB) GPU Info On-Demand Price/Hr Spot Price/Hr
------------- ----- --------- ---------- ----------- ------------------- -------- ------------------- ---- ---- ------------- -------- ------------------ -------------
u7in-32tb.224xlarge 896 32,768 nitro true false x86_64 200 Gigabit 16 0 0 none $407.68 -Not Fetched-
u7in-24tb.224xlarge 896 24,576 nitro true false x86_64 200 Gigabit 16 0 0 none $305.76 -Not Fetched-
u-24tb1.112xlarge 448 24,576 nitro true false x86_64 100 Gigabit 15 0 0 none $218.4 -Not Fetched-
u-18tb1.112xlarge 448 18,432 nitro true false x86_64 100 Gigabit 15 0 0 none $163.8 -Not Fetched-
u7in-16tb.224xlarge 896 16,384 nitro true false x86_64 200 Gigabit 16 0 0 none $203.84 -Not Fetched-
u7i-12tb.224xlarge 896 12,288 nitro true false x86_64 100 Gigabit 15 0 0 none $152.88 -Not Fetched-
u-12tb1.112xlarge 448 12,288 nitro true false x86_64 100 Gigabit 15 0 0 none $109.2 -Not Fetched-
u-9tb1.112xlarge 448 9,216 nitro true false x86_64 100 Gigabit 15 0 0 none $81.9 -Not Fetched-
u7i-8tb.112xlarge 448 8,192 nitro true false x86_64 100 Gigabit 15 0 0 none $83.72 -Not Fetched-
u-6tb1.56xlarge 224 6,144 nitro true false x86_64 100 Gigabit 15 0 0 none $46.40391 -Not Fetched-
NOTE: 855 entries were truncated, increase --max-results to see more
JSON path must point to a field in the [instancetype.Details struct](https://github.com/aws/amazon-ec2-instance-selector/blob/5bffbf2750ee09f5f1308bdc8d4b635a2c6e2721/pkg/instancetypes/instancetypes.go#L3
$ claude mcp add amazon-ec2-instance-selector \
-- python -m otcore.mcp_server <graph>