selector

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filters

type Filters struct {
	// AvailabilityZone 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 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
}

Filters is used to group instance type resource attributes for filtering

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) 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) RetrieveInstanceTypesSupportedInLocation

func (itf Selector) RetrieveInstanceTypesSupportedInLocation(zone string) (map[string]string, error)

RetrieveInstanceTypesSupportedInLocation returns a map of instance type -> AZ or Region for all instance types supported in the location 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

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