Skip to content

Commit 163c546

Browse files
authored
GPU and Accelerator Model and Manufacturer Support w/ free-tier, auto-recovery, dedicated-hosts, and cpu-manufacturer (#128)
* support model for gpus & accelerators, manufacturers for gpus, accelerators and cpus, and freeTier, dedicatedHosts, and autoRecovery * upgrade go to 1.18 * update readme * parallelized filter prep and processing * fix license test * fix inference model
1 parent a52d98e commit 163c546

File tree

11 files changed

+497
-298
lines changed

11 files changed

+497
-298
lines changed

Diff for: .github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: EC2 Instance Selector CI and Release
33
on: [push, pull_request, workflow_dispatch]
44

55
env:
6-
DEFAULT_GO_VERSION: ^1.17
6+
DEFAULT_GO_VERSION: ^1.18
77
GITHUB_USERNAME: ${{ secrets.EC2_BOT_GITHUB_USERNAME }}
88
GITHUB_TOKEN: ${{ secrets.EC2_BOT_GITHUB_TOKEN }}
99
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}

Diff for: Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.17 as builder
1+
FROM golang:1.18 as builder
22

33
## GOLANG env
44
ARG GOPROXY="https://proxy.golang.org|direct"

Diff for: README.md

+8
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,14 @@ ec2-instance-selector --memory-min 4 --memory-max 8 --vcpus-min 4 --vcpus-max 8
166166
167167
Filter Flags:
168168
--allow-list string List of allowed instance types to select from w/ regex syntax (Example: m[3-5]\.*)
169+
--auto-recovery EC2 Auto-Recovery supported
169170
-z, --availability-zones strings Availability zones or zone ids to check EC2 capacity offered in specific AZs
170171
--baremetal Bare Metal instance types (.metal instances)
171172
-b, --burst-support Burstable instance types
172173
-a, --cpu-architecture string CPU architecture [x86_64/amd64, x86_64_mac, i386, or arm64]
174+
--cpu-manufacturer string CPU manufacturer [amd, intel, aws]
173175
--current-generation Current generation instance types (explicitly set this to false to not return current generation instance types)
176+
--dedicated-hosts Dedicated Hosts supported
174177
--deny-list string List of instance types which should be excluded w/ regex syntax (Example: m[1-2]\.*)
175178
--disk-encryption EBS or local instance storage where encryption is supported or required
176179
--disk-type string Disk Type: [hdd or ssd]
@@ -187,14 +190,19 @@ Filter Flags:
187190
--efa-support Instance types that support Elastic Fabric Adapters (EFA)
188191
-e, --ena-support Instance types where ENA is supported or required
189192
-f, --fpga-support FPGA instance types
193+
--free-tier Free Tier supported
194+
--gpu-manufacturer string GPU Manufacturer name (Example: NVIDIA)
190195
--gpu-memory-total string Number of GPUs' total memory (Example: 4 GiB) (sets --gpu-memory-total-min and -max to the same value)
191196
--gpu-memory-total-max string Maximum Number of GPUs' total memory (Example: 4 GiB) If --gpu-memory-total-min is not specified, the lower bound will be 0
192197
--gpu-memory-total-min string Minimum Number of GPUs' total memory (Example: 4 GiB) If --gpu-memory-total-max is not specified, the upper bound will be infinity
198+
--gpu-model string GPU Model name (Example: K520)
193199
-g, --gpus int Total Number of GPUs (Example: 4) (sets --gpus-min and -max to the same value)
194200
--gpus-max int Maximum Total Number of GPUs (Example: 4) If --gpus-min is not specified, the lower bound will be 0
195201
--gpus-min int Minimum Total Number of GPUs (Example: 4) If --gpus-max is not specified, the upper bound will be infinity
196202
--hibernation-support Hibernation supported
197203
--hypervisor string Hypervisor: [xen or nitro]
204+
--inference-accelerator-manufacturer string Inference Accelerator Manufacturer name (Example: AWS)
205+
--inference-accelerator-model string Inference Accelerator Model name (Example: Inferentia)
198206
--inference-accelerators int Total Number of inference accelerators (Example: 4) (sets --inference-accelerators-min and -max to the same value)
199207
--inference-accelerators-max int Maximum Total Number of inference accelerators (Example: 4) If --inference-accelerators-min is not specified, the lower bound will be 0
200208
--inference-accelerators-min int Minimum Total Number of inference accelerators (Example: 4) If --inference-accelerators-max is not specified, the upper bound will be infinity

Diff for: THIRD_PARTY_LICENSES

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
github.com/aws/amazon-ec2-instance-selector (Apache-2.0) Third Party Licenses:
2+
---
3+
14
** aws-sdk-go; version v1.29.33 -- https://github.com/aws/aws-sdk-go
25
AWS SDK for Go
36
Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Diff for: cmd/main.go

+99-75
Original file line numberDiff line numberDiff line change
@@ -49,41 +49,49 @@ const (
4949

5050
// Filter Flag Constants
5151
const (
52-
vcpus = "vcpus"
53-
memory = "memory"
54-
vcpusToMemoryRatio = "vcpus-to-memory-ratio"
55-
cpuArchitecture = "cpu-architecture"
56-
gpus = "gpus"
57-
gpuMemoryTotal = "gpu-memory-total"
58-
inferenceAccelerators = "inference-accelerators"
59-
placementGroupStrategy = "placement-group-strategy"
60-
usageClass = "usage-class"
61-
rootDeviceType = "root-device-type"
62-
enaSupport = "ena-support"
63-
efaSupport = "efa-support"
64-
hibernationSupport = "hibernation-support"
65-
baremetal = "baremetal"
66-
fpgaSupport = "fpga-support"
67-
burstSupport = "burst-support"
68-
hypervisor = "hypervisor"
69-
availabilityZones = "availability-zones"
70-
currentGeneration = "current-generation"
71-
networkInterfaces = "network-interfaces"
72-
networkPerformance = "network-performance"
73-
networkEncryption = "network-encryption"
74-
ipv6 = "ipv6"
75-
allowList = "allow-list"
76-
denyList = "deny-list"
77-
virtualizationType = "virtualization-type"
78-
pricePerHour = "price-per-hour"
79-
instanceStorage = "instance-storage"
80-
diskType = "disk-type"
81-
diskEncryption = "disk-encryption"
82-
nvme = "nvme"
83-
ebsOptimized = "ebs-optimized"
84-
ebsOptimizedBaselineBandwidth = "ebs-optimized-baseline-bandwidth"
85-
ebsOptimizedBaselineThroughput = "ebs-optimized-baseline-throughput"
86-
ebsOptimizedBaselineIOPS = "ebs-optimized-baseline-iops"
52+
vcpus = "vcpus"
53+
memory = "memory"
54+
vcpusToMemoryRatio = "vcpus-to-memory-ratio"
55+
cpuArchitecture = "cpu-architecture"
56+
cpuManufacturer = "cpu-manufacturer"
57+
gpus = "gpus"
58+
gpuMemoryTotal = "gpu-memory-total"
59+
gpuManufacturer = "gpu-manufacturer"
60+
gpuModel = "gpu-model"
61+
inferenceAccelerators = "inference-accelerators"
62+
inferenceAcceleratorManufacturer = "inference-accelerator-manufacturer"
63+
inferenceAcceleratorModel = "inference-accelerator-model"
64+
placementGroupStrategy = "placement-group-strategy"
65+
usageClass = "usage-class"
66+
rootDeviceType = "root-device-type"
67+
enaSupport = "ena-support"
68+
efaSupport = "efa-support"
69+
hibernationSupport = "hibernation-support"
70+
baremetal = "baremetal"
71+
fpgaSupport = "fpga-support"
72+
burstSupport = "burst-support"
73+
hypervisor = "hypervisor"
74+
availabilityZones = "availability-zones"
75+
currentGeneration = "current-generation"
76+
networkInterfaces = "network-interfaces"
77+
networkPerformance = "network-performance"
78+
networkEncryption = "network-encryption"
79+
ipv6 = "ipv6"
80+
allowList = "allow-list"
81+
denyList = "deny-list"
82+
virtualizationType = "virtualization-type"
83+
pricePerHour = "price-per-hour"
84+
instanceStorage = "instance-storage"
85+
diskType = "disk-type"
86+
diskEncryption = "disk-encryption"
87+
nvme = "nvme"
88+
ebsOptimized = "ebs-optimized"
89+
ebsOptimizedBaselineBandwidth = "ebs-optimized-baseline-bandwidth"
90+
ebsOptimizedBaselineThroughput = "ebs-optimized-baseline-throughput"
91+
ebsOptimizedBaselineIOPS = "ebs-optimized-baseline-iops"
92+
freeTier = "free-tier"
93+
autoRecovery = "auto-recovery"
94+
dedicatedHosts = "dedicated-hosts"
8795
)
8896

8997
// Aggregate Filter Flags
@@ -141,9 +149,14 @@ Full docs can be found at github.com/aws/amazon-` + binName
141149
cli.ByteQuantityMinMaxRangeFlags(memory, cli.StringMe("m"), nil, "Amount of Memory available (Example: 4 GiB)")
142150
cli.RatioFlag(vcpusToMemoryRatio, nil, nil, "The ratio of vcpus to GiBs of memory. (Example: 1:2)")
143151
cli.StringOptionsFlag(cpuArchitecture, cli.StringMe("a"), nil, "CPU architecture [x86_64/amd64, x86_64_mac, i386, or arm64]", []string{"x86_64", "x86_64_mac", "amd64", "i386", "arm64"})
152+
cli.StringOptionsFlag(cpuManufacturer, nil, nil, "CPU manufacturer [amd, intel, aws]", []string{"amd", "intel", "aws"})
144153
cli.IntMinMaxRangeFlags(gpus, cli.StringMe("g"), nil, "Total Number of GPUs (Example: 4)")
145154
cli.ByteQuantityMinMaxRangeFlags(gpuMemoryTotal, nil, nil, "Number of GPUs' total memory (Example: 4 GiB)")
155+
cli.StringFlag(gpuManufacturer, nil, nil, "GPU Manufacturer name (Example: NVIDIA)", nil)
156+
cli.StringFlag(gpuModel, nil, nil, "GPU Model name (Example: K520)", nil)
146157
cli.IntMinMaxRangeFlags(inferenceAccelerators, nil, nil, "Total Number of inference accelerators (Example: 4)")
158+
cli.StringFlag(inferenceAcceleratorManufacturer, nil, nil, "Inference Accelerator Manufacturer name (Example: AWS)", nil)
159+
cli.StringFlag(inferenceAcceleratorModel, nil, nil, "Inference Accelerator Model name (Example: Inferentia)", nil)
147160
cli.StringOptionsFlag(placementGroupStrategy, nil, nil, "Placement group strategy: [cluster, partition, spread]", []string{"cluster", "partition", "spread"})
148161
cli.StringOptionsFlag(usageClass, cli.StringMe("u"), nil, "Usage class: [spot or on-demand]", []string{"spot", "on-demand"})
149162
cli.StringOptionsFlag(rootDeviceType, nil, nil, "Supported root device types: [ebs or instance-store]", []string{"ebs", "instance-store"})
@@ -172,6 +185,9 @@ Full docs can be found at github.com/aws/amazon-` + binName
172185
cli.ByteQuantityMinMaxRangeFlags(ebsOptimizedBaselineBandwidth, nil, nil, "EBS Optimized baseline bandwidth (Example: 4 GiB)")
173186
cli.ByteQuantityMinMaxRangeFlags(ebsOptimizedBaselineThroughput, nil, nil, "EBS Optimized baseline throughput per second (Example: 4 GiB)")
174187
cli.IntMinMaxRangeFlags(ebsOptimizedBaselineIOPS, nil, nil, "EBS Optimized baseline IOPS per second (Example: 10000)")
188+
cli.BoolFlag(freeTier, nil, nil, "Free Tier supported")
189+
cli.BoolFlag(autoRecovery, nil, nil, "EC2 Auto-Recovery supported")
190+
cli.BoolFlag(dedicatedHosts, nil, nil, "Dedicated Hosts supported")
175191

176192
// Suite Flags - higher level aggregate filters that return opinionated result
177193

@@ -247,46 +263,54 @@ Full docs can be found at github.com/aws/amazon-` + binName
247263
}
248264

249265
filters := selector.Filters{
250-
VCpusRange: cli.IntRangeMe(flags[vcpus]),
251-
MemoryRange: cli.ByteQuantityRangeMe(flags[memory]),
252-
VCpusToMemoryRatio: cli.Float64Me(flags[vcpusToMemoryRatio]),
253-
CPUArchitecture: cli.StringMe(flags[cpuArchitecture]),
254-
GpusRange: cli.IntRangeMe(flags[gpus]),
255-
GpuMemoryRange: cli.ByteQuantityRangeMe(flags[gpuMemoryTotal]),
256-
InferenceAcceleratorsRange: cli.IntRangeMe(flags[inferenceAccelerators]),
257-
PlacementGroupStrategy: cli.StringMe(flags[placementGroupStrategy]),
258-
UsageClass: cli.StringMe(flags[usageClass]),
259-
RootDeviceType: cli.StringMe(flags[rootDeviceType]),
260-
EnaSupport: cli.BoolMe(flags[enaSupport]),
261-
EfaSupport: cli.BoolMe(flags[efaSupport]),
262-
HibernationSupported: cli.BoolMe(flags[hibernationSupport]),
263-
Hypervisor: cli.StringMe(flags[hypervisor]),
264-
BareMetal: cli.BoolMe(flags[baremetal]),
265-
Fpga: cli.BoolMe(flags[fpgaSupport]),
266-
Burstable: cli.BoolMe(flags[burstSupport]),
267-
Region: cli.StringMe(flags[region]),
268-
AvailabilityZones: cli.StringSliceMe(flags[availabilityZones]),
269-
CurrentGeneration: cli.BoolMe(flags[currentGeneration]),
270-
MaxResults: cli.IntMe(flags[maxResults]),
271-
NetworkInterfaces: cli.IntRangeMe(flags[networkInterfaces]),
272-
NetworkPerformance: cli.IntRangeMe(flags[networkPerformance]),
273-
NetworkEncryption: cli.BoolMe(flags[networkEncryption]),
274-
IPv6: cli.BoolMe(flags[ipv6]),
275-
AllowList: cli.RegexMe(flags[allowList]),
276-
DenyList: cli.RegexMe(flags[denyList]),
277-
InstanceTypeBase: cli.StringMe(flags[instanceTypeBase]),
278-
Flexible: cli.BoolMe(flags[flexible]),
279-
Service: cli.StringMe(flags[service]),
280-
VirtualizationType: cli.StringMe(flags[virtualizationType]),
281-
PricePerHour: cli.Float64RangeMe(flags[pricePerHour]),
282-
InstanceStorageRange: cli.ByteQuantityRangeMe(flags[instanceStorage]),
283-
DiskType: cli.StringMe(flags[diskType]),
284-
DiskEncryption: cli.BoolMe(flags[diskEncryption]),
285-
NVME: cli.BoolMe(flags[nvme]),
286-
EBSOptimized: cli.BoolMe(flags[ebsOptimized]),
287-
EBSOptimizedBaselineBandwidth: cli.ByteQuantityRangeMe(flags[ebsOptimizedBaselineBandwidth]),
288-
EBSOptimizedBaselineThroughput: cli.ByteQuantityRangeMe(flags[ebsOptimizedBaselineThroughput]),
289-
EBSOptimizedBaselineIOPS: cli.IntRangeMe(flags[ebsOptimizedBaselineIOPS]),
266+
VCpusRange: cli.IntRangeMe(flags[vcpus]),
267+
MemoryRange: cli.ByteQuantityRangeMe(flags[memory]),
268+
VCpusToMemoryRatio: cli.Float64Me(flags[vcpusToMemoryRatio]),
269+
CPUArchitecture: cli.StringMe(flags[cpuArchitecture]),
270+
CPUManufacturer: cli.StringMe(flags[cpuManufacturer]),
271+
GpusRange: cli.IntRangeMe(flags[gpus]),
272+
GpuMemoryRange: cli.ByteQuantityRangeMe(flags[gpuMemoryTotal]),
273+
GPUManufacturer: cli.StringMe(flags[gpuManufacturer]),
274+
GPUModel: cli.StringMe(flags[gpuModel]),
275+
InferenceAcceleratorsRange: cli.IntRangeMe(flags[inferenceAccelerators]),
276+
InferenceAcceleratorManufacturer: cli.StringMe(flags[inferenceAcceleratorManufacturer]),
277+
InferenceAcceleratorModel: cli.StringMe(flags[inferenceAcceleratorModel]),
278+
PlacementGroupStrategy: cli.StringMe(flags[placementGroupStrategy]),
279+
UsageClass: cli.StringMe(flags[usageClass]),
280+
RootDeviceType: cli.StringMe(flags[rootDeviceType]),
281+
EnaSupport: cli.BoolMe(flags[enaSupport]),
282+
EfaSupport: cli.BoolMe(flags[efaSupport]),
283+
HibernationSupported: cli.BoolMe(flags[hibernationSupport]),
284+
Hypervisor: cli.StringMe(flags[hypervisor]),
285+
BareMetal: cli.BoolMe(flags[baremetal]),
286+
Fpga: cli.BoolMe(flags[fpgaSupport]),
287+
Burstable: cli.BoolMe(flags[burstSupport]),
288+
Region: cli.StringMe(flags[region]),
289+
AvailabilityZones: cli.StringSliceMe(flags[availabilityZones]),
290+
CurrentGeneration: cli.BoolMe(flags[currentGeneration]),
291+
MaxResults: cli.IntMe(flags[maxResults]),
292+
NetworkInterfaces: cli.IntRangeMe(flags[networkInterfaces]),
293+
NetworkPerformance: cli.IntRangeMe(flags[networkPerformance]),
294+
NetworkEncryption: cli.BoolMe(flags[networkEncryption]),
295+
IPv6: cli.BoolMe(flags[ipv6]),
296+
AllowList: cli.RegexMe(flags[allowList]),
297+
DenyList: cli.RegexMe(flags[denyList]),
298+
InstanceTypeBase: cli.StringMe(flags[instanceTypeBase]),
299+
Flexible: cli.BoolMe(flags[flexible]),
300+
Service: cli.StringMe(flags[service]),
301+
VirtualizationType: cli.StringMe(flags[virtualizationType]),
302+
PricePerHour: cli.Float64RangeMe(flags[pricePerHour]),
303+
InstanceStorageRange: cli.ByteQuantityRangeMe(flags[instanceStorage]),
304+
DiskType: cli.StringMe(flags[diskType]),
305+
DiskEncryption: cli.BoolMe(flags[diskEncryption]),
306+
NVME: cli.BoolMe(flags[nvme]),
307+
EBSOptimized: cli.BoolMe(flags[ebsOptimized]),
308+
EBSOptimizedBaselineBandwidth: cli.ByteQuantityRangeMe(flags[ebsOptimizedBaselineBandwidth]),
309+
EBSOptimizedBaselineThroughput: cli.ByteQuantityRangeMe(flags[ebsOptimizedBaselineThroughput]),
310+
EBSOptimizedBaselineIOPS: cli.IntRangeMe(flags[ebsOptimizedBaselineIOPS]),
311+
FreeTier: cli.BoolMe(flags[freeTier]),
312+
AutoRecovery: cli.BoolMe(flags[autoRecovery]),
313+
DedicatedHosts: cli.BoolMe(flags[dedicatedHosts]),
290314
}
291315

292316
if flags[verbose] != nil {

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/aws/amazon-ec2-instance-selector/v2
22

3-
go 1.17
3+
go 1.18
44

55
require (
66
github.com/aws/aws-sdk-go v1.43.31

0 commit comments

Comments
 (0)