Skip to content

Commit

Permalink
GPU and Accelerator Model and Manufacturer Support w/ free-tier, auto…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
bwagner5 authored Apr 11, 2022
1 parent a52d98e commit 163c546
Show file tree
Hide file tree
Showing 11 changed files with 497 additions and 298 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: EC2 Instance Selector CI and Release
on: [push, pull_request, workflow_dispatch]

env:
DEFAULT_GO_VERSION: ^1.17
DEFAULT_GO_VERSION: ^1.18
GITHUB_USERNAME: ${{ secrets.EC2_BOT_GITHUB_USERNAME }}
GITHUB_TOKEN: ${{ secrets.EC2_BOT_GITHUB_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17 as builder
FROM golang:1.18 as builder

## GOLANG env
ARG GOPROXY="https://proxy.golang.org|direct"
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,14 @@ ec2-instance-selector --memory-min 4 --memory-max 8 --vcpus-min 4 --vcpus-max 8
Filter Flags:
--allow-list string List of allowed instance types to select from w/ regex syntax (Example: m[3-5]\.*)
--auto-recovery EC2 Auto-Recovery supported
-z, --availability-zones strings Availability zones or zone ids to check EC2 capacity offered in specific AZs
--baremetal Bare Metal instance types (.metal instances)
-b, --burst-support Burstable instance types
-a, --cpu-architecture string CPU architecture [x86_64/amd64, x86_64_mac, i386, or arm64]
--cpu-manufacturer string CPU manufacturer [amd, intel, aws]
--current-generation Current generation instance types (explicitly set this to false to not return current generation instance types)
--dedicated-hosts Dedicated Hosts supported
--deny-list string List of instance types which should be excluded w/ regex syntax (Example: m[1-2]\.*)
--disk-encryption EBS or local instance storage where encryption is supported or required
--disk-type string Disk Type: [hdd or ssd]
Expand All @@ -187,14 +190,19 @@ Filter Flags:
--efa-support Instance types that support Elastic Fabric Adapters (EFA)
-e, --ena-support Instance types where ENA is supported or required
-f, --fpga-support FPGA instance types
--free-tier Free Tier supported
--gpu-manufacturer string GPU Manufacturer name (Example: NVIDIA)
--gpu-memory-total string Number of GPUs' total memory (Example: 4 GiB) (sets --gpu-memory-total-min and -max to the same value)
--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
--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
--gpu-model string GPU Model name (Example: K520)
-g, --gpus int Total Number of GPUs (Example: 4) (sets --gpus-min and -max to the same value)
--gpus-max int Maximum Total Number of GPUs (Example: 4) If --gpus-min is not specified, the lower bound will be 0
--gpus-min int Minimum Total Number of GPUs (Example: 4) If --gpus-max is not specified, the upper bound will be infinity
--hibernation-support Hibernation supported
--hypervisor string Hypervisor: [xen or nitro]
--inference-accelerator-manufacturer string Inference Accelerator Manufacturer name (Example: AWS)
--inference-accelerator-model string Inference Accelerator Model name (Example: Inferentia)
--inference-accelerators int Total Number of inference accelerators (Example: 4) (sets --inference-accelerators-min and -max to the same value)
--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
--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
Expand Down
3 changes: 3 additions & 0 deletions THIRD_PARTY_LICENSES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
github.com/aws/amazon-ec2-instance-selector (Apache-2.0) Third Party Licenses:
---

** aws-sdk-go; version v1.29.33 -- https://github.com/aws/aws-sdk-go
AWS SDK for Go
Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down
174 changes: 99 additions & 75 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,49 @@ const (

// Filter Flag Constants
const (
vcpus = "vcpus"
memory = "memory"
vcpusToMemoryRatio = "vcpus-to-memory-ratio"
cpuArchitecture = "cpu-architecture"
gpus = "gpus"
gpuMemoryTotal = "gpu-memory-total"
inferenceAccelerators = "inference-accelerators"
placementGroupStrategy = "placement-group-strategy"
usageClass = "usage-class"
rootDeviceType = "root-device-type"
enaSupport = "ena-support"
efaSupport = "efa-support"
hibernationSupport = "hibernation-support"
baremetal = "baremetal"
fpgaSupport = "fpga-support"
burstSupport = "burst-support"
hypervisor = "hypervisor"
availabilityZones = "availability-zones"
currentGeneration = "current-generation"
networkInterfaces = "network-interfaces"
networkPerformance = "network-performance"
networkEncryption = "network-encryption"
ipv6 = "ipv6"
allowList = "allow-list"
denyList = "deny-list"
virtualizationType = "virtualization-type"
pricePerHour = "price-per-hour"
instanceStorage = "instance-storage"
diskType = "disk-type"
diskEncryption = "disk-encryption"
nvme = "nvme"
ebsOptimized = "ebs-optimized"
ebsOptimizedBaselineBandwidth = "ebs-optimized-baseline-bandwidth"
ebsOptimizedBaselineThroughput = "ebs-optimized-baseline-throughput"
ebsOptimizedBaselineIOPS = "ebs-optimized-baseline-iops"
vcpus = "vcpus"
memory = "memory"
vcpusToMemoryRatio = "vcpus-to-memory-ratio"
cpuArchitecture = "cpu-architecture"
cpuManufacturer = "cpu-manufacturer"
gpus = "gpus"
gpuMemoryTotal = "gpu-memory-total"
gpuManufacturer = "gpu-manufacturer"
gpuModel = "gpu-model"
inferenceAccelerators = "inference-accelerators"
inferenceAcceleratorManufacturer = "inference-accelerator-manufacturer"
inferenceAcceleratorModel = "inference-accelerator-model"
placementGroupStrategy = "placement-group-strategy"
usageClass = "usage-class"
rootDeviceType = "root-device-type"
enaSupport = "ena-support"
efaSupport = "efa-support"
hibernationSupport = "hibernation-support"
baremetal = "baremetal"
fpgaSupport = "fpga-support"
burstSupport = "burst-support"
hypervisor = "hypervisor"
availabilityZones = "availability-zones"
currentGeneration = "current-generation"
networkInterfaces = "network-interfaces"
networkPerformance = "network-performance"
networkEncryption = "network-encryption"
ipv6 = "ipv6"
allowList = "allow-list"
denyList = "deny-list"
virtualizationType = "virtualization-type"
pricePerHour = "price-per-hour"
instanceStorage = "instance-storage"
diskType = "disk-type"
diskEncryption = "disk-encryption"
nvme = "nvme"
ebsOptimized = "ebs-optimized"
ebsOptimizedBaselineBandwidth = "ebs-optimized-baseline-bandwidth"
ebsOptimizedBaselineThroughput = "ebs-optimized-baseline-throughput"
ebsOptimizedBaselineIOPS = "ebs-optimized-baseline-iops"
freeTier = "free-tier"
autoRecovery = "auto-recovery"
dedicatedHosts = "dedicated-hosts"
)

// Aggregate Filter Flags
Expand Down Expand Up @@ -141,9 +149,14 @@ Full docs can be found at github.com/aws/amazon-` + binName
cli.ByteQuantityMinMaxRangeFlags(memory, cli.StringMe("m"), nil, "Amount of Memory available (Example: 4 GiB)")
cli.RatioFlag(vcpusToMemoryRatio, nil, nil, "The ratio of vcpus to GiBs of memory. (Example: 1:2)")
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"})
cli.StringOptionsFlag(cpuManufacturer, nil, nil, "CPU manufacturer [amd, intel, aws]", []string{"amd", "intel", "aws"})
cli.IntMinMaxRangeFlags(gpus, cli.StringMe("g"), nil, "Total Number of GPUs (Example: 4)")
cli.ByteQuantityMinMaxRangeFlags(gpuMemoryTotal, nil, nil, "Number of GPUs' total memory (Example: 4 GiB)")
cli.StringFlag(gpuManufacturer, nil, nil, "GPU Manufacturer name (Example: NVIDIA)", nil)
cli.StringFlag(gpuModel, nil, nil, "GPU Model name (Example: K520)", nil)
cli.IntMinMaxRangeFlags(inferenceAccelerators, nil, nil, "Total Number of inference accelerators (Example: 4)")
cli.StringFlag(inferenceAcceleratorManufacturer, nil, nil, "Inference Accelerator Manufacturer name (Example: AWS)", nil)
cli.StringFlag(inferenceAcceleratorModel, nil, nil, "Inference Accelerator Model name (Example: Inferentia)", nil)
cli.StringOptionsFlag(placementGroupStrategy, nil, nil, "Placement group strategy: [cluster, partition, spread]", []string{"cluster", "partition", "spread"})
cli.StringOptionsFlag(usageClass, cli.StringMe("u"), nil, "Usage class: [spot or on-demand]", []string{"spot", "on-demand"})
cli.StringOptionsFlag(rootDeviceType, nil, nil, "Supported root device types: [ebs or instance-store]", []string{"ebs", "instance-store"})
Expand Down Expand Up @@ -172,6 +185,9 @@ Full docs can be found at github.com/aws/amazon-` + binName
cli.ByteQuantityMinMaxRangeFlags(ebsOptimizedBaselineBandwidth, nil, nil, "EBS Optimized baseline bandwidth (Example: 4 GiB)")
cli.ByteQuantityMinMaxRangeFlags(ebsOptimizedBaselineThroughput, nil, nil, "EBS Optimized baseline throughput per second (Example: 4 GiB)")
cli.IntMinMaxRangeFlags(ebsOptimizedBaselineIOPS, nil, nil, "EBS Optimized baseline IOPS per second (Example: 10000)")
cli.BoolFlag(freeTier, nil, nil, "Free Tier supported")
cli.BoolFlag(autoRecovery, nil, nil, "EC2 Auto-Recovery supported")
cli.BoolFlag(dedicatedHosts, nil, nil, "Dedicated Hosts supported")

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

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

filters := selector.Filters{
VCpusRange: cli.IntRangeMe(flags[vcpus]),
MemoryRange: cli.ByteQuantityRangeMe(flags[memory]),
VCpusToMemoryRatio: cli.Float64Me(flags[vcpusToMemoryRatio]),
CPUArchitecture: cli.StringMe(flags[cpuArchitecture]),
GpusRange: cli.IntRangeMe(flags[gpus]),
GpuMemoryRange: cli.ByteQuantityRangeMe(flags[gpuMemoryTotal]),
InferenceAcceleratorsRange: cli.IntRangeMe(flags[inferenceAccelerators]),
PlacementGroupStrategy: cli.StringMe(flags[placementGroupStrategy]),
UsageClass: cli.StringMe(flags[usageClass]),
RootDeviceType: cli.StringMe(flags[rootDeviceType]),
EnaSupport: cli.BoolMe(flags[enaSupport]),
EfaSupport: cli.BoolMe(flags[efaSupport]),
HibernationSupported: cli.BoolMe(flags[hibernationSupport]),
Hypervisor: cli.StringMe(flags[hypervisor]),
BareMetal: cli.BoolMe(flags[baremetal]),
Fpga: cli.BoolMe(flags[fpgaSupport]),
Burstable: cli.BoolMe(flags[burstSupport]),
Region: cli.StringMe(flags[region]),
AvailabilityZones: cli.StringSliceMe(flags[availabilityZones]),
CurrentGeneration: cli.BoolMe(flags[currentGeneration]),
MaxResults: cli.IntMe(flags[maxResults]),
NetworkInterfaces: cli.IntRangeMe(flags[networkInterfaces]),
NetworkPerformance: cli.IntRangeMe(flags[networkPerformance]),
NetworkEncryption: cli.BoolMe(flags[networkEncryption]),
IPv6: cli.BoolMe(flags[ipv6]),
AllowList: cli.RegexMe(flags[allowList]),
DenyList: cli.RegexMe(flags[denyList]),
InstanceTypeBase: cli.StringMe(flags[instanceTypeBase]),
Flexible: cli.BoolMe(flags[flexible]),
Service: cli.StringMe(flags[service]),
VirtualizationType: cli.StringMe(flags[virtualizationType]),
PricePerHour: cli.Float64RangeMe(flags[pricePerHour]),
InstanceStorageRange: cli.ByteQuantityRangeMe(flags[instanceStorage]),
DiskType: cli.StringMe(flags[diskType]),
DiskEncryption: cli.BoolMe(flags[diskEncryption]),
NVME: cli.BoolMe(flags[nvme]),
EBSOptimized: cli.BoolMe(flags[ebsOptimized]),
EBSOptimizedBaselineBandwidth: cli.ByteQuantityRangeMe(flags[ebsOptimizedBaselineBandwidth]),
EBSOptimizedBaselineThroughput: cli.ByteQuantityRangeMe(flags[ebsOptimizedBaselineThroughput]),
EBSOptimizedBaselineIOPS: cli.IntRangeMe(flags[ebsOptimizedBaselineIOPS]),
VCpusRange: cli.IntRangeMe(flags[vcpus]),
MemoryRange: cli.ByteQuantityRangeMe(flags[memory]),
VCpusToMemoryRatio: cli.Float64Me(flags[vcpusToMemoryRatio]),
CPUArchitecture: cli.StringMe(flags[cpuArchitecture]),
CPUManufacturer: cli.StringMe(flags[cpuManufacturer]),
GpusRange: cli.IntRangeMe(flags[gpus]),
GpuMemoryRange: cli.ByteQuantityRangeMe(flags[gpuMemoryTotal]),
GPUManufacturer: cli.StringMe(flags[gpuManufacturer]),
GPUModel: cli.StringMe(flags[gpuModel]),
InferenceAcceleratorsRange: cli.IntRangeMe(flags[inferenceAccelerators]),
InferenceAcceleratorManufacturer: cli.StringMe(flags[inferenceAcceleratorManufacturer]),
InferenceAcceleratorModel: cli.StringMe(flags[inferenceAcceleratorModel]),
PlacementGroupStrategy: cli.StringMe(flags[placementGroupStrategy]),
UsageClass: cli.StringMe(flags[usageClass]),
RootDeviceType: cli.StringMe(flags[rootDeviceType]),
EnaSupport: cli.BoolMe(flags[enaSupport]),
EfaSupport: cli.BoolMe(flags[efaSupport]),
HibernationSupported: cli.BoolMe(flags[hibernationSupport]),
Hypervisor: cli.StringMe(flags[hypervisor]),
BareMetal: cli.BoolMe(flags[baremetal]),
Fpga: cli.BoolMe(flags[fpgaSupport]),
Burstable: cli.BoolMe(flags[burstSupport]),
Region: cli.StringMe(flags[region]),
AvailabilityZones: cli.StringSliceMe(flags[availabilityZones]),
CurrentGeneration: cli.BoolMe(flags[currentGeneration]),
MaxResults: cli.IntMe(flags[maxResults]),
NetworkInterfaces: cli.IntRangeMe(flags[networkInterfaces]),
NetworkPerformance: cli.IntRangeMe(flags[networkPerformance]),
NetworkEncryption: cli.BoolMe(flags[networkEncryption]),
IPv6: cli.BoolMe(flags[ipv6]),
AllowList: cli.RegexMe(flags[allowList]),
DenyList: cli.RegexMe(flags[denyList]),
InstanceTypeBase: cli.StringMe(flags[instanceTypeBase]),
Flexible: cli.BoolMe(flags[flexible]),
Service: cli.StringMe(flags[service]),
VirtualizationType: cli.StringMe(flags[virtualizationType]),
PricePerHour: cli.Float64RangeMe(flags[pricePerHour]),
InstanceStorageRange: cli.ByteQuantityRangeMe(flags[instanceStorage]),
DiskType: cli.StringMe(flags[diskType]),
DiskEncryption: cli.BoolMe(flags[diskEncryption]),
NVME: cli.BoolMe(flags[nvme]),
EBSOptimized: cli.BoolMe(flags[ebsOptimized]),
EBSOptimizedBaselineBandwidth: cli.ByteQuantityRangeMe(flags[ebsOptimizedBaselineBandwidth]),
EBSOptimizedBaselineThroughput: cli.ByteQuantityRangeMe(flags[ebsOptimizedBaselineThroughput]),
EBSOptimizedBaselineIOPS: cli.IntRangeMe(flags[ebsOptimizedBaselineIOPS]),
FreeTier: cli.BoolMe(flags[freeTier]),
AutoRecovery: cli.BoolMe(flags[autoRecovery]),
DedicatedHosts: cli.BoolMe(flags[dedicatedHosts]),
}

if flags[verbose] != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aws/amazon-ec2-instance-selector/v2

go 1.17
go 1.18

require (
github.com/aws/aws-sdk-go v1.43.31
Expand Down
Loading

0 comments on commit 163c546

Please sign in to comment.