selector

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package selector provides filtering logic for Amazon EC2 Instance Types based on declarative resource specfications.

Index

Constants

View Source
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 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

	// AvailabilityZone [DEPRECATED] is the AWS Availability Zone where instances will be provisioned.
	// Instance type capacity can vary between availability zones.
	// Will accept zone name or id
	// Example: us-east-1a, us-east-1b, us-east-2a, etc. OR use1-az1, use2-az2, etc.
	AvailabilityZone *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

	// CPUArchitecture of the EC2 instance type
	// Possible values are: x86_64/amd64 or arm64
	CPUArchitecture *string

	// CurrentGeneration returns the latest generation of instance types
	CurrentGeneration *bool

	// EnaSupport returns instances that can support an Elastic Network Adapter.
	EnaSupport *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 available to an EC2 instance type in aggreagte across all GPUs.
	GpuMemoryRange *IntRangeFilter

	// 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 Mebibytes (MiB) for the instance type
	MemoryRange *IntRangeFilter

	// 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

	// 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
}

Filters is used to group instance type resource attributes for filtering

func (*Filters) MarshalIndent added in v1.3.0

func (f *Filters) MarshalIndent(prefix, indent string) ([]byte, error)

MarshalIndent is used to return a pretty-print json representation of a Filters struct

type FiltersTransform added in v1.3.0

type FiltersTransform interface {
	Transform(Filters) (Filters, error)
}

FiltersTransform can be implemented to provide custom transforms

type InstanceTypesOutput

type InstanceTypesOutput interface {
	Output([]*ec2.InstanceTypeInfo) []string
}

InstanceTypesOutput can be implemented to provide custom output to instance type results

type InstanceTypesOutputFn

type InstanceTypesOutputFn func([]*ec2.InstanceTypeInfo) []string

InstanceTypesOutputFn is the func type definition for InstanceTypesOuput

func (InstanceTypesOutputFn) Output

func (fn InstanceTypesOutputFn) Output(instanceTypes []*ec2.InstanceTypeInfo) []string

Output implements InstanceTypesOutput interface on InstanceTypesOutputFn This allows any InstanceTypesOutputFn to be passed into funcs accepting InstanceTypesOutput interface

type IntRangeFilter

type IntRangeFilter struct {
	UpperBound int
	LowerBound int
}

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
}

Selector is used to filter instance type resource specs

func New

func New(sess *session.Session) *Selector

New creates an instance of Selector provided an aws session

func (Selector) AggregateFilterTransform added in v1.1.0

func (itf Selector) AggregateFilterTransform(filters Filters) (Filters, error)

AggregateFilterTransform takes higher level filters which are used to affect multiple raw filters in an opinionated way.

func (Selector) Filter

func (itf Selector) Filter(filters Filters) ([]string, error)

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

func (Selector) FilterVerbose

func (itf Selector) FilterVerbose(filters Filters) ([]*ec2.InstanceTypeInfo, 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

func (Selector) FilterWithOutput

func (itf Selector) FilterWithOutput(filters Filters, outputFn InstanceTypesOutput) ([]string, 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

func (Selector) RetrieveInstanceTypesSupportedInLocations added in v1.1.0

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 added in v1.3.0

func (itf Selector) TransformBaseInstanceType(filters Filters) (Filters, error)

TransformBaseInstanceType transforms lower level filters based on the instanceTypeBase specs

func (Selector) TransformFlexible added in v1.3.0

func (itf Selector) TransformFlexible(filters Filters) (Filters, error)

TransformFlexible transforms lower level filters based on a set of opinions

type TransformFn added in v1.3.0

type TransformFn func(Filters) (Filters, error)

TransformFn is the func type definition for a FiltersTransform

func (TransformFn) Transform added in v1.3.0

func (fn TransformFn) Transform(filters Filters) (Filters, error)

Transform implements FiltersTransform interface on TransformFn This allows any TransformFn to be passed into funcs accepting FiltersTransform interface

Directories

Path Synopsis
Package outputs provides types for implementing instance type output functions as well as prebuilt output functions.
Package outputs provides types for implementing instance type output functions as well as prebuilt output functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL