ricost

package
v0.0.0-...-a99bcb5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: OSL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ricost holds the convertible Reserved Instance cost formula shared by the reshape recommendations API (internal/api) and the auto-exchange and ladder paths (internal/server), so the two can't drift apart.

Index

Constants

View Source
const HoursPerMonth = 730.0

HoursPerMonth is AWS's canonical hours-per-month convention for monthly cost figures: 8760 hours in a 365-day year divided by 12 months. It matches hoursPerMonth in cloud-commitments-go's providers/aws/recommendations and the 730-hour monthly rates used elsewhere in the platform.

Variables

View Source
var (
	ErrNonPositiveDuration = errors.New("non-positive duration")
	ErrNoPricing           = errors.New("no positive price")
)

Sentinel causes for MonthlyCostFromConvertibleRI's error, so the reshape API can show each excluded RI's reason.

Functions

func MonthlyCostFromConvertibleRI

func MonthlyCostFromConvertibleRI(ri ec2svc.ConvertibleRI) (float64, error)

MonthlyCostFromConvertibleRI computes the per-instance per-month effective cost from an RI's pricing fields, matching the formula the AWS effectiveMonthlyCost function uses for offerings:

monthly = (FixedPrice / hours_per_term + UsagePrice + recurring_hourly) × HoursPerMonth

Returns an error when Duration is non-positive or when the computed cost is not positive (for example FixedPrice, UsagePrice and RecurringHourlyAmount all zero, which means AWS returned no pricing, not a free RI, issue #1188): a zero cost would read as a free RI and skip reshape's dollar-units pricing gate, so callers must exclude the RI. The error wraps ErrNonPositiveDuration or ErrNoPricing.

Used to populate exchange.RIInfo.MonthlyCost so the cross-family dollar-units pre-filter compares against per-target offering costs computed with the same formula.

Types

This section is empty.

Jump to

Keyboard shortcuts

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