Documentation
¶
Index ¶
- type EC2Pricing
- func (p *EC2Pricing) GetOndemandInstanceTypeCost(instanceType string) (float64, error)
- func (p *EC2Pricing) GetSpotInstanceTypeNDayAvgCost(instanceType string, availabilityZones []string, days int) (float64, error)
- func (p *EC2Pricing) HydrateOndemandCache() error
- func (p *EC2Pricing) HydrateSpotCache(days int) error
- type EC2PricingIface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EC2Pricing ¶
type EC2Pricing struct { PricingClient pricingiface.PricingAPI EC2Client ec2iface.EC2API AWSSession *session.Session // contains filtered or unexported fields }
EC2Pricing is the public struct to interface with AWS pricing APIs
func New ¶
func New(sess *session.Session) *EC2Pricing
New creates an instance of instance-selector EC2Pricing
func (*EC2Pricing) GetOndemandInstanceTypeCost ¶
func (p *EC2Pricing) GetOndemandInstanceTypeCost(instanceType string) (float64, error)
GetOndemandInstanceTypeCost retrieves the on-demand hourly cost for the specified instance type
func (*EC2Pricing) GetSpotInstanceTypeNDayAvgCost ¶
func (p *EC2Pricing) GetSpotInstanceTypeNDayAvgCost(instanceType string, availabilityZones []string, days int) (float64, error)
GetSpotInstanceTypeNDayAvgCost retrieves the spot price history for a given AZ from the past N days and averages the price Passing an empty list for availabilityZones will retrieve avg cost for all AZs in the current AWSSession's region
func (*EC2Pricing) HydrateOndemandCache ¶
func (p *EC2Pricing) HydrateOndemandCache() error
HydrateOndemandCache makes a bulk request to the pricing api to retrieve all instance type pricing and stores them in a local cache If HydrateOndemandCache is called more than once, the cache will be fully refreshed There is no TTL on cache entries
func (*EC2Pricing) HydrateSpotCache ¶
func (p *EC2Pricing) HydrateSpotCache(days int) error
HydrateSpotCache makes a bulk request to the spot-pricing-history api to retrieve all instance type pricing and stores them in a local cache If HydrateSpotCache is called more than once, the cache will be fully refreshed There is no TTL on cache entries You'll only want to use this if you don't mind a long startup time (around 30 seconds) and will query the cache often after that.
type EC2PricingIface ¶
type EC2PricingIface interface { GetOndemandInstanceTypeCost(instanceType string) (float64, error) GetSpotInstanceTypeNDayAvgCost(instanceType string, availabilityZones []string, days int) (float64, error) HydrateOndemandCache() error HydrateSpotCache(days int) error }
EC2PricingIface is the EC2Pricing interface mainly used to mock out ec2pricing during testing