ec2instancereferenceprice

package
v0.0.0-...-fbda710 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const Collection = "ec2_instance_reference_prices"

Collection is the MongoDB collection for EC2 reference median prices.

Variables

View Source
var (
	// BSON field names for queries (aligned with struct tags).
	InstanceTypeKey    = bsonutil.MustHaveTag(EC2InstanceReferencePrice{}, "InstanceType")
	OperatingSystemKey = bsonutil.MustHaveTag(EC2InstanceReferencePrice{}, "OperatingSystem")
)

Functions

func ApplyReferenceCostDataOrWarn

func ApplyReferenceCostDataOrWarn(ctx context.Context, d *distro.Distro)

ApplyReferenceCostDataOrWarn fills CostData from the EC2 reference price row for this distro's instance type and OS, or zeros rates and logs critically if none are found.

func ByInstanceTypeAndOS

func ByInstanceTypeAndOS(instanceType, operatingSystem string) db.Q

ByInstanceTypeAndOS returns a query for the natural key used by reference pricing. operatingSystem is matched case-insensitively so rows stay valid whether the collection stores Linux/linux, SUSE/suse, etc.

func OperatingSystemFromImageID

func OperatingSystemFromImageID(imageID string) string

OperatingSystemFromImageID maps distro image_id naming to lowercase OS keys for reference pricing. Substring checks are case-insensitive.

Types

type EC2InstanceReferencePrice

type EC2InstanceReferencePrice struct {
	InstanceType          string  `bson:"instance_type" json:"instance_type"`
	OperatingSystem       string  `bson:"operating_system" json:"operating_system"`
	OnDemandMedian        float64 `bson:"on_demand_median" json:"on_demand_median"`
	AdjustedFinanceMedian float64 `bson:"adjusted_finance_median" json:"adjusted_finance_median"`
}

EC2InstanceReferencePrice holds median on-demand and finance-adjusted hourly rates for an instance type and OS, used to validate distro cost_data.

func FindOne

func FindOne(ctx context.Context, query db.Q) (*EC2InstanceReferencePrice, error)

FindOne runs a query against the reference price collection, returning one document.

Jump to

Keyboard shortcuts

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