Documentation ¶
Overview ¶
Package selector provides filtering logic for Amazon EC2 Instance Types based on declarative resource specfications.
Index ¶
- Constants
- type ByteQuantityRangeFilter
- type EKS
- type EMR
- type Filters
- type FiltersTransform
- type Float64RangeFilter
- type InstanceTypesOutput
- type InstanceTypesOutputFn
- type IntRangeFilter
- type Selector
- func (itf Selector) AggregateFilterTransform(filters Filters) (Filters, error)
- func (itf Selector) Filter(filters Filters) ([]string, error)deprecated
- func (itf Selector) FilterVerbose(filters Filters) ([]*instancetypes.Details, error)deprecated
- func (itf Selector) FilterWithOutput(filters Filters, outputFn InstanceTypesOutput) ([]string, int, error)deprecated
- func (itf Selector) RetrieveInstanceTypesSupportedInLocations(locations []string) (map[string]string, error)
- func (itf Selector) Save() error
- func (itf Selector) TransformBaseInstanceType(filters Filters) (Filters, error)
- func (itf Selector) TransformFlexible(filters Filters) (Filters, error)
- func (itf Selector) TransformForService(filters Filters) (Filters, error)
- type Service
- type ServiceFiltersFn
- type ServiceRegistry
- type TransformFn
- type Uint64RangeFilter
Constants ¶
const ( // AggregateLowPercentile is the default lower percentile for resource ranges on similar instance type comparisons AggregateLowPercentile = 0.9 // AggregateHighPercentile is the default upper percentile for resource ranges on similar instance type comparisons AggregateHighPercentile = 1.2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteQuantityRangeFilter ¶
type ByteQuantityRangeFilter struct { UpperBound bytequantity.ByteQuantity LowerBound bytequantity.ByteQuantity }
ByteQuantityRangeFilter holds an upper and lower bound byte quantity The lower and upper bound are used to range filter resource specs
type EKS ¶ added in v2.0.3
type EKS struct {
AMIRepoURL string
}
EKS is a Service type for a custom service filter transform
type EMR ¶ added in v2.0.3
type EMR struct{}
EMR is a Service type for a custom service filter transform
type Filters ¶
type Filters struct { // AvailabilityZones is the AWS Availability Zones where instances will be provisioned. // Instance type capacity can vary between availability zones. // Will accept zone names or ids // Example: us-east-1a, us-east-1b, us-east-2a, etc. OR use1-az1, use2-az2, etc. AvailabilityZones *[]string // BareMetal is used to only return bare metal instance type results BareMetal *bool // Burstable is used to only return burstable instance type results like the t* series Burstable *bool // AutoRecovery is used to filter by instance types that support auto recovery AutoRecovery *bool // FreeTier is used to filter by instance types that can be used as part of the EC2 free tier FreeTier *bool // CPUArchitecture of the EC2 instance type // Possible values are: x86_64/amd64 or arm64 CPUArchitecture *string // CPUManufacturer is used to filter instance types with a specific CPU manufacturer CPUManufacturer *string // CurrentGeneration returns the latest generation of instance types CurrentGeneration *bool // EnaSupport returns instances that can support an Elastic Network Adapter. EnaSupport *bool // EfaSupport returns instances that can support an Elastic Fabric Adapter. EfaSupport *bool // FPGA is used to only return FPGA instance type results Fpga *bool // GpusRange filter is a range of acceptable GPU count available to an EC2 instance type GpusRange *IntRangeFilter // GpuMemoryRange filter is a range of acceptable GPU memory in Gibibytes (GiB) available to an EC2 instance type in aggreagte across all GPUs. GpuMemoryRange *ByteQuantityRangeFilter // GPUManufacturer filters by GPU manufacturer GPUManufacturer *string // GPUModel filter by the GPU model name GPUModel *string // InferenceAcceleratorsRange filters inference accelerators available to the instance type InferenceAcceleratorsRange *IntRangeFilter // InferenceAcceleratorManufacturer filters by inference acceleartor manufacturer InferenceAcceleratorManufacturer *string // InferenceAcceleratorModel filters by inference accelerator model name InferenceAcceleratorModel *string // HibernationSupported denotes whether EC2 hibernate is supported // Possible values are: true or false HibernationSupported *bool // Hypervisor is used to return only a specific hypervisor backed instance type // Possibly values are: xen or nitro Hypervisor *string // MaxResults is the maximum number of instance types to return that match the filter criteria MaxResults *int // MemoryRange filter is a range of acceptable DRAM memory in Gibibytes (GiB) for the instance type MemoryRange *ByteQuantityRangeFilter // NetworkInterfaces filter is a range of the number of ENI attachments an instance type can support NetworkInterfaces *IntRangeFilter // NetworkPerformance filter is a range of network bandwidth an instance type can support NetworkPerformance *IntRangeFilter // NetworkEncryption filters for instance types that automatically encrypt network traffic in-transit NetworkEncryption *bool // IPv6 filters for instance types that support IPv6 IPv6 *bool // PlacementGroupStrategy is used to return instance types based on its support // for a specific placement group strategy // Possible values are: cluster, spread, or partition PlacementGroupStrategy *string // Region is the AWS Region where instances will be provisioned. // Instance type availability can vary between AWS Regions. // Example: us-east-1, us-east-2, eu-west-1, etc. Region *string // RootDeviceType is the backing device of the root storage volume // Possible values are: instance-store or ebs RootDeviceType *string // UsageClass of the instance EC2 instance type // Possible values are: spot or on-demand UsageClass *string // VCpusRange filter is a range of acceptable VCpus for the instance type VCpusRange *IntRangeFilter // VcpusToMemoryRatio is a ratio of vcpus to memory expressed as a floating point VCpusToMemoryRatio *float64 // AllowList is a regex of allowed instance types AllowList *regexp.Regexp // DenyList is a regex of excluded instance types DenyList *regexp.Regexp // InstanceTypeBase is a base instance type which is used to retrieve similarly spec'd instance types InstanceTypeBase *string // Flexible finds an opinionated set of general (c, m, r, t, a, etc.) instance types that match a criteria specified // or defaults to 4 vcpus Flexible *bool // Service filters instance types based on a service's supported list of instance types // Example: eks or emr Service *string // InstanceTypes filters instance types and only allows instance types in this slice InstanceTypes *[]string // VirtualizationType is used to return instance types that match either hvm or pv virtualization types VirtualizationType *string // PricePerHour is used to return instance types that are equal to or cheaper than the specified price PricePerHour *Float64RangeFilter // InstanceStorageRange filters on a range of storage available as local disk InstanceStorageRange *ByteQuantityRangeFilter // DiskType is the backing storage medium // Possible values are: hdd or ssd DiskType *string // NVME filters for NVME disks, including both EBS and local instance storage NVME *bool // EBSOptimized filters for instance types that support EBS Optimized EBSOptimized *bool // DiskEncryption filters for instance types that support EBS Encryption or local storage encryption DiskEncryption *bool // EBSOptimizedBaselineBandwidth filters on a range of bandwidth that an EBS Optimized volume supports EBSOptimizedBaselineBandwidth *ByteQuantityRangeFilter // EBSOptimizedBaselineThroughput filters on a range of throughput that an EBS Optimized volume supports EBSOptimizedBaselineThroughput *ByteQuantityRangeFilter // EBSOptimizedBaselineIOPS filters on a range of IOPS that an EBS Optimized volume supports EBSOptimizedBaselineIOPS *IntRangeFilter // DedicatedHosts filters on instance types that support dedicated hosts tenancy DedicatedHosts *bool }
Filters is used to group instance type resource attributes for filtering
type FiltersTransform ¶
FiltersTransform can be implemented to provide custom transforms
type Float64RangeFilter ¶ added in v2.0.3
Float64RangeFilter holds an upper and lower bound float64 The lower and upper bound are used to range filter resource specs
type InstanceTypesOutput ¶
type InstanceTypesOutput interface {
Output([]*instancetypes.Details) []string
}
InstanceTypesOutput can be implemented to provide custom output to instance type results
type InstanceTypesOutputFn ¶
type InstanceTypesOutputFn func([]*instancetypes.Details) []string
InstanceTypesOutputFn is the func type definition for InstanceTypesOuput
func (InstanceTypesOutputFn) Output ¶
func (fn InstanceTypesOutputFn) Output(instanceTypes []*instancetypes.Details) []string
Output implements InstanceTypesOutput interface on InstanceTypesOutputFn This allows any InstanceTypesOutputFn to be passed into funcs accepting InstanceTypesOutput interface
type IntRangeFilter ¶
IntRangeFilter holds an upper and lower bound int The lower and upper bound are used to range filter resource specs
type Selector ¶
type Selector struct { EC2 ec2iface.EC2API EC2Pricing ec2pricing.EC2PricingIface InstanceTypesProvider *instancetypes.Provider ServiceRegistry ServiceRegistry }
Selector is used to filter instance type resource specs
func NewWithCache ¶ added in v2.1.0
func (Selector) AggregateFilterTransform ¶
AggregateFilterTransform takes higher level filters which are used to affect multiple raw filters in an opinionated way.
func (Selector) Filter
deprecated
Filter accepts a Filters struct which is used to select the available instance types matching the criteria within Filters and returns a simple list of instance type strings
Deprecated: This function will be replaced with GetFilteredInstanceTypes() and OutputInstanceTypes() in the next major version.
func (Selector) FilterVerbose
deprecated
func (itf Selector) FilterVerbose(filters Filters) ([]*instancetypes.Details, error)
FilterVerbose accepts a Filters struct which is used to select the available instance types matching the criteria within Filters and returns a list instanceTypeInfo
Deprecated: This function will be replaced with GetFilteredInstanceTypes() in the next major version.
func (Selector) FilterWithOutput
deprecated
func (itf Selector) FilterWithOutput(filters Filters, outputFn InstanceTypesOutput) ([]string, int, error)
FilterWithOutput accepts a Filters struct which is used to select the available instance types matching the criteria within Filters and returns a list of strings based on the custom outputFn
Deprecated: This function will be replaced with GetFilteredInstanceTypes() and OutputInstanceTypes() in the next major version.
func (Selector) RetrieveInstanceTypesSupportedInLocations ¶
func (itf Selector) RetrieveInstanceTypesSupportedInLocations(locations []string) (map[string]string, error)
RetrieveInstanceTypesSupportedInLocations returns a map of instance type -> AZ or Region for all instance types supported in the intersected locations passed in The location can be a zone-id (ie. use1-az1), a zone-name (us-east-1a), or a region name (us-east-1). Note that zone names are not necessarily the same across accounts
func (Selector) TransformBaseInstanceType ¶
TransformBaseInstanceType transforms lower level filters based on the instanceTypeBase specs
func (Selector) TransformFlexible ¶
TransformFlexible transforms lower level filters based on a set of opinions
type ServiceFiltersFn ¶ added in v2.0.3
ServiceFiltersFn is the func type definition for the Service interface
type ServiceRegistry ¶ added in v2.0.3
type ServiceRegistry struct {
// contains filtered or unexported fields
}
ServiceRegistry is used to register service filter transforms
func NewRegistry ¶ added in v2.0.3
func NewRegistry() ServiceRegistry
NewRegistry creates a new instance of a ServiceRegistry
func (*ServiceRegistry) ExecuteTransforms ¶ added in v2.0.3
func (sr *ServiceRegistry) ExecuteTransforms(filters Filters) (Filters, error)
ExecuteTransforms will execute the ServiceRegistry's registered service filter transforms Filters.Service will be parsed as <service-name>-<version> and passed to Service.Filters
func (*ServiceRegistry) Register ¶ added in v2.0.3
func (sr *ServiceRegistry) Register(name string, service Service)
Register takes a service name and Service implementation that will be executed on an ExecuteTransforms call
func (*ServiceRegistry) RegisterAWSServices ¶ added in v2.0.3
func (sr *ServiceRegistry) RegisterAWSServices()
RegisterAWSServices registers the built-in AWS service filter transforms
type TransformFn ¶
TransformFn is the func type definition for a FiltersTransform
type Uint64RangeFilter ¶
Uint64RangeFilter holds an upper and lower bound uint64 The lower and upper bound are used to range filter resource specs