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 ¶
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 ¶
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.