ce

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 29 Imported by: ? 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.

README

Cost Explorer

Parity grade: A · SDK aws-sdk-go-v2/service/costexplorer@v1.74.0 · last audited 2026-10-07 (24813b443)

Coverage

Metric Value
PARITY entries audited 37 (37 ok)
Feature families 13 (13 ok)
Known gaps none
Structural gaps (can't be emulated) 5
Deferred items 2
Resource leaks clean
Structural gaps

These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.

  • GetReservationCoverage/Utilization and GetSavingsPlansCoverage GroupBy: groups need per-reservation and per-plan inventory (SUBSCRIPTION_ID, AZ, PLATFORM, TENANCY); the ledger only has service, region, account and usage type.
  • GetSavingsPlansCoverage SortBy/Metrics and GetSavingsPlansUtilizationDetails SortBy: the single synthetic result row makes any ordering or metric selection unobservable.
  • AnomalyMonitor.LastEvaluatedDate: no anomaly-detection engine evaluates monitors, so there is no evaluation time to report.
  • BillingViewArn (11 ops) and ListCostCategoryDefinitions.SupportedResourceTypes: no billing-view service or per-category resource-type model exists to scope results by.
  • GetReservationPurchaseRecommendation per OfferingClass: no per-class pricing data exists.
Deferred
  • Reservation/SavingsPlans numeric-formula fidelity (the specific ratios in backend.go's syntheticServiceCatalog / spCommitmentRatio / riPurchasedCostRatio etc.) -- these produce plausible, internally-consistent numbers but were not cross-checked against any real AWS CE billing behavior; by definition there is no real data to match against, so this is a modeling-quality concern for a future pass, not a correctness bug.
  • ListCostCategoryResourceAssociations.CostCategoryResourceAssociations is always empty: it needs a cost-category-to-resource association inventory this emulator does not model.

More

Documentation

Overview

Package ce provides an in-memory implementation of the AWS Cost Explorer (Ce) service.

Index

Constants

View Source
const DefaultAnomalyTTL = 30 * 24 * time.Hour

DefaultAnomalyTTL is the default time-to-live for detected anomalies.

View Source
const ExcludeChargeTypeFilter = "ExcludeChargeType"

ExcludeChargeTypeFilter is the LedgerSpend filter key listing charge types to leave out.

View Source
const (

	// ResourceRetentionDays is how long resource-level rows are kept, per GetCostAndUsageWithResources.
	ResourceRetentionDays = 14
)

Variables

View Source
var (
	// ErrNotFound is returned when a requested resource does not exist.
	ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound)
	// ErrAlreadyExists is returned when a resource with the same name already exists.
	ErrAlreadyExists = awserr.New("ServiceQuotaExceededException", awserr.ErrConflict)
	// ErrValidation is returned when input parameters fail validation. Real AWS CE's
	// documented common-error type for malformed/missing-required-member requests is
	// "ValidationError" (confirmed via the CE API reference's CommonErrors page), not a
	// named per-operation exception -- CE's errors.go typed-exception list (checked
	// against aws-sdk-go-v2/service/costexplorer/types) has no ValidationException or
	// InvalidParameterException entry for any operation in this audit.
	ErrValidation = errors.New("ValidationError")
	// ErrDataUnavailable is returned when queried data is not available for the time range.
	ErrDataUnavailable = awserr.New("DataUnavailableException", awserr.ErrNotFound)
	// ErrInvalidNextToken is returned for a NextPageToken that matches no page boundary.
	ErrInvalidNextToken = awserr.New("InvalidNextTokenException", awserr.ErrInvalidParameter)
	// ErrUnknownMonitor is returned when a referenced cost anomaly monitor ARN does not
	// exist. Real AWS CE returns this (not the generic ResourceNotFoundException) from
	// every anomaly-monitor op and from any op whose MonitorArnList references a monitor
	// that doesn't exist.
	ErrUnknownMonitor = awserr.New("UnknownMonitorException", awserr.ErrNotFound)
	// ErrUnknownSubscription is returned when a referenced cost anomaly subscription ARN
	// does not exist. Real AWS CE returns this (not the generic ResourceNotFoundException)
	// from every anomaly-subscription op.
	ErrUnknownSubscription = awserr.New("UnknownSubscriptionException", awserr.ErrNotFound)
)

Functions

func Hourly

func Hourly(gb float64) float64

Hourly returns the per-hour quantity for gb gigabytes held under a GB-Mo price.

Types

type Anomaly

type Anomaly struct {
	CreationDate     time.Time          `json:"creationDate"`
	AnomalyID        string             `json:"anomalyID"`
	AnomalyStartDate string             `json:"anomalyStartDate"`
	AnomalyEndDate   string             `json:"anomalyEndDate"`
	DimensionValue   string             `json:"dimensionValue"`
	MonitorARN       string             `json:"monitorARN"`
	SubscriptionARN  string             `json:"subscriptionARN"`
	FeedbackType     string             `json:"feedbackType"`
	RootCauses       []AnomalyRootCause `json:"rootCauses,omitempty"`
	AnomalyScore     AnomalyScore       `json:"anomalyScore"`
	TotalImpact      float64            `json:"totalImpact"`
}

Anomaly represents a detected cost anomaly in AWS CE.

type AnomalyMonitor

type AnomalyMonitor struct {
	CreationDate         time.Time         `json:"creationDate"`
	LastUpdatedDate      time.Time         `json:"lastUpdatedDate"`
	Tags                 map[string]string `json:"tags"`
	MonitorSpecification *ceExpression     `json:"monitorSpecification,omitempty"`
	MonitorARN           string            `json:"monitorARN"`
	MonitorName          string            `json:"monitorName"`
	MonitorType          string            `json:"monitorType"`
	MonitorDimension     string            `json:"monitorDimension"`
}

AnomalyMonitor represents an in-memory AWS CE anomaly monitor. MonitorSpecification is the Expression that scopes a CUSTOM monitor (or a DIMENSIONAL monitor with MonitorDimension TAG/COST_CATEGORY) -- required input on CreateAnomalyMonitor, echoed back on GetAnomalyMonitors per types.AnomalyMonitor (costexplorer@v1.67.4 types/types.go).

type AnomalyRootCause

type AnomalyRootCause struct {
	Service       string `json:"Service,omitempty"`
	Region        string `json:"Region,omitempty"`
	LinkedAccount string `json:"LinkedAccount,omitempty"`
	UsageType     string `json:"UsageType,omitempty"`
}

AnomalyRootCause identifies a root cause dimension for an anomaly.

type AnomalyScore

type AnomalyScore struct {
	MaxScore     float64 `json:"MaxScore"`
	CurrentScore float64 `json:"CurrentScore"`
}

AnomalyScore represents the anomaly detection score.

type AnomalySubscription

type AnomalySubscription struct {
	CreationDate        time.Time         `json:"creationDate"`
	Tags                map[string]string `json:"tags"`
	ThresholdExpression *ceExpression     `json:"thresholdExpression,omitempty"`
	SubscriptionARN     string            `json:"subscriptionARN"`
	SubscriptionName    string            `json:"subscriptionName"`
	AccountID           string            `json:"accountID"`
	Frequency           string            `json:"frequency"`
	MonitorARNList      []string          `json:"monitorARNList"`
	Subscribers         []Subscriber      `json:"subscribers"`
	Threshold           float64           `json:"threshold"`
}

AnomalySubscription represents an in-memory AWS CE anomaly subscription. ThresholdExpression is the non-deprecated alternative to Threshold (real AWS: "you can specify either Threshold or ThresholdExpression, but not both" -- costexplorer@v1.67.4 types/types.go's AnomalySubscription doc comment); both CreateAnomalySubscriptionInput and UpdateAnomalySubscriptionInput accept it.

type BackfillJob

type BackfillJob struct {
	BackfillID     string `json:"backfillID"`
	BackfillFrom   string `json:"backfillFrom"`
	RequestedAt    string `json:"requestedAt"`
	CompletedAt    string `json:"completedAt,omitempty"`
	BackfillStatus string `json:"backfillStatus"` // SUCCEEDED|PROCESSING|FAILED
	LastUpdatedAt  string `json:"lastUpdatedAt"`
}

BackfillJob represents a cost allocation tag backfill job. BackfillID is internal-only -- real AWS's CostAllocationTagBackfillRequest has no unique identifier field at all (NextToken is fully opaque), so this is not a fabricated wire field, just a stable sort/pagination key this backend needs since RequestedAt alone (second precision) can tie between jobs created in the same second.

type CommitmentAnalysis

type CommitmentAnalysis struct {
	Configuration           any    `json:"configuration,omitempty"`
	AnalysisID              string `json:"analysisId"`
	AnalysisStatus          string `json:"analysisStatus"` // SUCCEEDED|PROCESSING|FAILED
	AnalysisStartedTime     string `json:"analysisStartedTime"`
	EstimatedCompletionTime string `json:"estimatedCompletionTime"`
	ErrorCode               string `json:"errorCode,omitempty"`
}

CommitmentAnalysis represents a commitment purchase analysis.

type CostAllocationTag

type CostAllocationTag struct {
	TagKey          string `json:"tagKey"`
	Status          string `json:"status"` // Active | Inactive
	Type            string `json:"type"`   // AWSGenerated | UserDefined
	LastUpdatedDate string `json:"lastUpdatedDate"`
}

CostAllocationTag represents an AWS CE cost allocation tag.

type CostAllocationTagError

type CostAllocationTagError struct {
	TagKey  string `json:"TagKey"`
	Code    string `json:"Code"`
	Message string `json:"Message"`
}

CostAllocationTagError holds an error for a single tag key update.

type CostAllocationTagStatusEntry

type CostAllocationTagStatusEntry struct {
	TagKey string `json:"TagKey"`
	Status string `json:"Status"`
}

CostAllocationTagStatusEntry is a TagKey+Status pair for UpdateCostAllocationTagsStatus.

type CostCategory

type CostCategory struct {
	CreationDate     time.Time          `json:"creationDate"`
	Tags             map[string]string  `json:"tags"`
	ARN              string             `json:"arn"`
	Name             string             `json:"name"`
	RuleVersion      string             `json:"ruleVersion"`
	DefaultValue     string             `json:"defaultValue"`
	EffectiveStart   string             `json:"effectiveStart"`
	Rules            []CostCategoryRule `json:"rules"`
	SplitChargeRules []SplitChargeRule  `json:"splitChargeRules"`
}

CostCategory represents an in-memory AWS Cost Explorer cost category.

type CostCategoryRule

type CostCategoryRule struct {
	Rule           *ceExpression  `json:"rule,omitempty"`
	InheritedValue *inheritedRule `json:"inheritedValue,omitempty"`
	Value          string         `json:"value"`
	Type           string         `json:"type,omitempty"`
}

CostCategoryRule represents a single cost category rule.

type CostEntry

type CostEntry struct {
	Tags map[string]string `json:"tags"`
	// ProductAttributes carries the Budgets ProductAttributes dimensions (feature, inferenceType, model, provider).
	ProductAttributes map[string]string `json:"productAttributes,omitempty"`
	Date              string            `json:"date"`
	Service           string            `json:"service"`
	Region            string            `json:"region"`
	UsageType         string            `json:"usageType"`
	Account           string            `json:"account"`
	ChargeType        string            `json:"chargeType,omitempty"`
	// SubscriptionID is the Savings Plans or reservation subscription the entry belongs to.
	SubscriptionID string `json:"subscriptionId,omitempty"`
	// The fields from AvailabilityZone to ResourceID are additive ledger dimensions.
	AvailabilityZone string  `json:"availabilityZone,omitempty"`
	InstanceType     string  `json:"instanceType,omitempty"`
	Operation        string  `json:"operation,omitempty"`
	PurchaseType     string  `json:"purchaseType,omitempty"`
	UsageTypeGroup   string  `json:"usageTypeGroup,omitempty"`
	ProductFamily    string  `json:"productFamily,omitempty"`
	ResourceID       string  `json:"resourceId,omitempty"`
	BlendedCost      float64 `json:"blendedCost"`
	UnblendedCost    float64 `json:"unblendedCost"`
	UsageQuantity    float64 `json:"usageQuantity"`
}

CostEntry is a synthetic cost ledger entry for a single day+service combination.

type CostGroup

type CostGroup struct {
	Metrics map[string]MetricValue `json:"Metrics"`
	Keys    []string               `json:"Keys"`
}

CostGroup represents a group in a cost result.

type ForecastResult

type ForecastResult struct {
	TimePeriod                   map[string]string `json:"TimePeriod"`
	MeanValue                    string            `json:"MeanValue"`
	PredictionIntervalLowerBound string            `json:"PredictionIntervalLowerBound,omitempty"`
	PredictionIntervalUpperBound string            `json:"PredictionIntervalUpperBound,omitempty"`
}

ForecastResult represents a single time-bucket forecast entry.

type GroupBySpec

type GroupBySpec struct {
	Type string `json:"Type"`
	Key  string `json:"Key"`
}

GroupBySpec represents a single GroupBy dimension spec.

type Handler

type Handler struct {
	Backend *InMemoryBackend
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for Cost Explorer (Ce) operations.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a new Cost Explorer handler backed by backend. backend must not be nil.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations returns all operations that can be fault-injected.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns all regions this handler instance handles.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase AWS service name for fault rule matching.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation extracts the Cost Explorer action from the X-Amz-Target header.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(_ *echo.Context) string

ExtractResource extracts the resource identifier from the request (not used for Ce).

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns the list of supported operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler function for Cost Explorer requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset implements service.Resettable by delegating to the backend.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher returns a function that matches Cost Explorer requests.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker books usage for held resources (running instances, stored bytes) every minute until ctx is cancelled.

type Holding

type Holding struct{ Usage Usage }

Holding is a resource held over time; Usage.Quantity is the amount accrued per hour held.

type HoldingSource

type HoldingSource func() []Holding

HoldingSource lists the resources currently held by a service (running instances, stored bytes, ...).

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend is a thread-safe in-memory store for Cost Explorer resources.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates a new backend for the given account and region.

func (*InMemoryBackend) Accrue

func (b *InMemoryBackend) Accrue()

Accrue books usage for every held resource over the time since the previous accrual.

func (*InMemoryBackend) AddAnomaly

func (b *InMemoryBackend) AddAnomaly(a Anomaly)

AddAnomaly inserts an anomaly into the backend. It is intended for testing.

func (*InMemoryBackend) AddHoldingSource

func (b *InMemoryBackend) AddHoldingSource(src HoldingSource)

AddHoldingSource registers a service whose held resources accrue usage for the time they exist.

func (*InMemoryBackend) AddUsageSource

func (b *InMemoryBackend) AddUsageSource(src UsageSource)

AddUsageSource registers a service whose accumulated usage is drained into the ledger on every accrual.

func (*InMemoryBackend) CostCategoryValue

func (b *InMemoryBackend) CostCategoryValue(name string, e *CostEntry) string

CostCategoryValue returns the value the named cost category assigns to e: the first matching rule's value, else the category's default value; empty when the category does not exist or nothing applies.

func (*InMemoryBackend) CreateAnomalyMonitor

func (b *InMemoryBackend) CreateAnomalyMonitor(
	monitorName, monitorType, monitorDimension string,
	monitorSpecification *ceExpression,
	resourceTags map[string]string,
) (*AnomalyMonitor, error)

CreateAnomalyMonitor creates a new anomaly monitor.

func (*InMemoryBackend) CreateAnomalySubscription

func (b *InMemoryBackend) CreateAnomalySubscription(
	subscriptionName, frequency string,
	monitorARNList []string,
	subscribers []Subscriber,
	threshold float64,
	thresholdExpression *ceExpression,
	resourceTags map[string]string,
) (*AnomalySubscription, error)

CreateAnomalySubscription creates a new anomaly subscription.

func (*InMemoryBackend) CreateBackfillJob

func (b *InMemoryBackend) CreateBackfillJob(backfillFrom string) *BackfillJob

CreateBackfillJob creates a new cost allocation tag backfill job.

func (*InMemoryBackend) CreateCommitmentAnalysis

func (b *InMemoryBackend) CreateCommitmentAnalysis(configuration any) *CommitmentAnalysis

CreateCommitmentAnalysis starts a new commitment purchase analysis. configuration is stored and echoed back verbatim on Get/List/Start (real GetCommitmentPurchaseAnalysisOutput/AnalysisSummary both carry CommitmentPurchaseAnalysisConfiguration) -- this backend doesn't simulate analysis internals, so it round-trips the request's configuration rather than fabricating computed contents.

func (*InMemoryBackend) CreateCostCategoryDefinition

func (b *InMemoryBackend) CreateCostCategoryDefinition(
	name, ruleVersion, defaultValue string,
	rules []CostCategoryRule,
	resourceTags map[string]string,
	splitChargeRules []SplitChargeRule,
	requestedEffectiveStart string,
) (*CostCategory, error)

CreateCostCategoryDefinition creates a new cost category and returns it. requestedEffectiveStart, when non-empty, overrides the default "first day of the current month" real AWS also defaults to when the field is omitted (api_op_CreateCostCategoryDefinition.go).

func (*InMemoryBackend) CreateSavingsPlansGeneration added in v1.2.0

func (b *InMemoryBackend) CreateSavingsPlansGeneration() *SavingsPlansGeneration

CreateSavingsPlansGeneration starts a new Savings Plans purchase recommendation generation job and persists it, mirroring the CommitmentAnalysis start/persist/list/get pattern used elsewhere in this backend.

func (*InMemoryBackend) DeleteAnomalyMonitor

func (b *InMemoryBackend) DeleteAnomalyMonitor(monARN string) error

DeleteAnomalyMonitor removes an anomaly monitor by ARN.

func (*InMemoryBackend) DeleteAnomalySubscription

func (b *InMemoryBackend) DeleteAnomalySubscription(subARN string) error

DeleteAnomalySubscription removes an anomaly subscription by ARN.

func (*InMemoryBackend) DeleteCostCategoryDefinition

func (b *InMemoryBackend) DeleteCostCategoryDefinition(catARN string) (*CostCategory, error)

DeleteCostCategoryDefinition removes a cost category by ARN.

func (*InMemoryBackend) DescribeCostCategoryDefinition

func (b *InMemoryBackend) DescribeCostCategoryDefinition(catARN string) (*CostCategory, error)

DescribeCostCategoryDefinition returns a cost category by ARN.

func (*InMemoryBackend) DimensionValueCost added in v1.3.1

func (b *InMemoryBackend) DimensionValueCost(dimension, value, metric string) float64

DimensionValueCost sums the requested cost metric ("UnblendedCost" or any other value, which defaults to BlendedCost) across ledger entries whose `dimension` equals value. Used to give GetDimensionValues' SortBy a real, non-fabricated ordering over the returned dimension values.

func (*InMemoryBackend) GetAnomalies

func (b *InMemoryBackend) GetAnomalies(
	monitorARN, feedback, startDate, endDate string, maxResults int, nextPageToken string,
	totalImpact *TotalImpactFilter,
) ([]*Anomaly, string)

GetAnomalies returns detected anomalies, optionally filtered by monitor ARN, feedback type, date interval, and total dollar impact. maxResults and nextPageToken implement opaque-cursor pagination.

func (*InMemoryBackend) GetAnomalyMonitors

func (b *InMemoryBackend) GetAnomalyMonitors(
	monitorARNList []string, maxResults int, nextPageToken string,
) ([]*AnomalyMonitor, string, error)

GetAnomalyMonitors returns anomaly monitors, optionally filtered by ARNs, sorted by MonitorARN. maxResults and nextPageToken implement opaque-cursor pagination (real AWS behaviour). If monitorARNList references an ARN that doesn't exist, it returns ErrUnknownMonitor, matching real AWS.

func (*InMemoryBackend) GetAnomalySubscriptions

func (b *InMemoryBackend) GetAnomalySubscriptions(
	subscriptionARNList []string,
	monitorARN string,
	maxResults int,
	nextPageToken string,
) ([]*AnomalySubscription, string, error)

GetAnomalySubscriptions returns anomaly subscriptions, optionally filtered by ARNs or monitor ARN, sorted by SubscriptionARN. maxResults and nextPageToken implement opaque-cursor pagination. If subscriptionARNList references an ARN that doesn't exist, it returns ErrUnknownSubscription, matching real AWS. monitorARN is a simple filter (real AWS does not require it to reference an existing monitor).

func (*InMemoryBackend) GetApproximateUsageRecords added in v1.2.0

func (b *InMemoryBackend) GetApproximateUsageRecords(
	services []string,
) (string, string, map[string]int64, int64)

GetApproximateUsageRecords returns estimated per-service usage record counts derived from the cost ledger's UsageQuantity over the trailing daysPerMonth-day lookback window, optionally filtered to services. Matches real AWS's GetApproximateUsageRecords shape: LookbackPeriod + per-service counts + a grand total.

func (*InMemoryBackend) GetCommitmentAnalysis

func (b *InMemoryBackend) GetCommitmentAnalysis(analysisID string) (*CommitmentAnalysis, error)

GetCommitmentAnalysis retrieves a commitment analysis by ID.

func (*InMemoryBackend) GetCostAndUsage

func (b *InMemoryBackend) GetCostAndUsage(
	start, end, granularity string,
	metrics []string,
	groupBy []GroupBySpec,
	serviceFilter []string,
) []ResultByTime

GetCostAndUsage aggregates cost ledger entries by granularity, applying optional GroupBy. serviceFilter only narrows by the SERVICE dimension; callers that need the full Filter expression (Dimensions on any modeled dimension, Tags, And/Or/Not) must use GetCostAndUsageFiltered instead.

func (*InMemoryBackend) GetCostAndUsageFiltered

func (b *InMemoryBackend) GetCostAndUsageFiltered(
	start, end, granularity string,
	metrics []string,
	groupBy []GroupBySpec,
	filter *ceExpression,
) []ResultByTime

GetCostAndUsageFiltered is GetCostAndUsage with the full Filter expression (Dimensions on any modeled dimension, Tags, And/Or/Not) applied via matchesExpression, instead of GetCostAndUsage's SERVICE-only narrowing.

func (*InMemoryBackend) GetCostAndUsageWithResources

func (b *InMemoryBackend) GetCostAndUsageWithResources(
	start, end, granularity string,
	metrics []string,
	groupBy []GroupBySpec,
	filter *ceExpression,
) []ResultByTime

GetCostAndUsageWithResources is GetCostAndUsageFiltered over the resource-level rows only (those with a resource id).

func (*InMemoryBackend) GetCostCategories

func (b *InMemoryBackend) GetCostCategories(costCategoryName string) []string

GetCostCategories returns the distinct cost category values stored in the backend, optionally filtered by cost category name. Values are sorted alphabetically.

func (*InMemoryBackend) GetCostCategoryNames added in v1.3.1

func (b *InMemoryBackend) GetCostCategoryNames() []string

GetCostCategoryNames returns the distinct cost category names stored in the backend, sorted alphabetically. Real GetCostCategories emits this list instead of CostCategoryValues when the request omits CostCategoryName (see api_op_GetCostCategories.go: "If the CostCategoryName key isn't specified in the request, the CostCategoryValues fields aren't returned").

func (*InMemoryBackend) GetDimensionValues

func (b *InMemoryBackend) GetDimensionValues(dimension string) []string

GetDimensionValues returns unique values for the given dimension from the cost ledger.

func (*InMemoryBackend) GetDimensionValuesFiltered added in v1.3.1

func (b *InMemoryBackend) GetDimensionValuesFiltered(
	dimension, constraintDimension string, constraintValues []string,
) []string

GetDimensionValuesFiltered returns unique values for `dimension`, restricted to ledger entries whose `constraintDimension` value is one of constraintValues (when constraintDimension is non-empty). This gives a real, non-fabricated effect to GetDimensionValuesInput.Filter when it carries a single (non-nested) Dimensions clause.

func (*InMemoryBackend) GetForecastByTime

func (b *InMemoryBackend) GetForecastByTime(
	start, end, granularity, metric string,
	predictionIntervalLevel int,
	serviceFilter []string,
) ([]ForecastResult, float64, float64, float64)

GetForecastByTime returns per-bucket cost/usage forecasts for a time range, computed from the requested metric (GetCostForecastInput/ GetUsageForecastInput.Metric) over ledger entries narrowed by serviceFilter (GetCostForecastInput/GetUsageForecastInput.Filter's SERVICE dimension), matching the same pattern used across this file. A prior revision always used BlendedCost and ignored Filter regardless of what was requested.

func (*InMemoryBackend) GetReservationCoverage

func (b *InMemoryBackend) GetReservationCoverage(
	start, end, granularity string,
) []ReservationCoverageByTime

GetReservationCoverage returns synthetic RI coverage by time.

func (*InMemoryBackend) GetReservationCoverageFiltered added in v1.3.1

func (b *InMemoryBackend) GetReservationCoverageFiltered(
	start, end, granularity string, serviceFilter []string,
) []ReservationCoverageByTime

GetReservationCoverageFiltered is GetReservationCoverage narrowed to ledger entries whose Service is in serviceFilter (when non-empty), giving GetReservationCoverageInput.Filter's SERVICE dimension a real, non-fabricated effect. Other documented Filter dimensions (AZ, PLATFORM, TENANCY, ...) have no per-entry breakdown in this emulator's ledger and are not applied.

func (*InMemoryBackend) GetReservationPurchaseRecommendations

func (b *InMemoryBackend) GetReservationPurchaseRecommendations(
	service, lookback, term, payment string,
) []ReservationRecommendation

GetReservationPurchaseRecommendations returns synthetic RI purchase recommendations.

func (*InMemoryBackend) GetReservationUtilization

func (b *InMemoryBackend) GetReservationUtilization(
	start, end, granularity string,
) []ReservationUtilizationByTime

GetReservationUtilization returns synthetic RI utilization by time.

func (*InMemoryBackend) GetReservationUtilizationFiltered added in v1.3.1

func (b *InMemoryBackend) GetReservationUtilizationFiltered(
	start, end, granularity string, serviceFilter []string,
) []ReservationUtilizationByTime

GetReservationUtilizationFiltered is GetReservationUtilization narrowed to ledger entries whose Service is in serviceFilter (when non-empty), giving GetReservationUtilizationInput.Filter's SERVICE dimension a real, non-fabricated effect. Other documented Filter dimensions (AZ, PLATFORM, TENANCY, ...) have no per-entry breakdown in this emulator's ledger and are not applied.

func (*InMemoryBackend) GetRightsizingRecommendations

func (b *InMemoryBackend) GetRightsizingRecommendations(
	_ string,
) []RightsizingRecommendation

GetRightsizingRecommendations returns synthetic rightsizing recommendations.

func (*InMemoryBackend) GetSavingsPlansUtilization

func (b *InMemoryBackend) GetSavingsPlansUtilization(
	start, end string,
) *SavingsPlansUtilizationResult

GetSavingsPlansUtilization returns a synthetic savings-plans utilization aggregate.

func (*InMemoryBackend) GetSavingsPlansUtilizationDetails

func (b *InMemoryBackend) GetSavingsPlansUtilizationDetails(
	start, end string,
) []SavingsPlansUtilizationDetail

GetSavingsPlansUtilizationDetails returns per-plan utilization details.

func (*InMemoryBackend) GetTagKeys

func (b *InMemoryBackend) GetTagKeys() []string

GetTagKeys returns all distinct tag keys used across the cost ledger.

func (*InMemoryBackend) GetTagKeysFiltered added in v1.3.1

func (b *InMemoryBackend) GetTagKeysFiltered(constraintKey string, constraintValues []string) []string

GetTagKeysFiltered returns distinct tag keys, restricted to ledger entries whose `constraintKey` tag value is one of constraintValues (when constraintKey is non-empty). Gives GetTagsInput.Filter's Tags clause a real, non-fabricated effect.

func (*InMemoryBackend) GetTagValues

func (b *InMemoryBackend) GetTagValues(tagKey string) []string

GetTagValues returns distinct values for a tag key.

func (*InMemoryBackend) GetTagValuesFiltered added in v1.3.1

func (b *InMemoryBackend) GetTagValuesFiltered(tagKey, constraintKey string, constraintValues []string) []string

GetTagValuesFiltered returns distinct values of tagKey, restricted to ledger entries whose `constraintKey` tag value is one of constraintValues (when constraintKey is non-empty).

func (*InMemoryBackend) InventoryResources

func (b *InMemoryBackend) InventoryResources() []TaggedEntry

InventoryResources lists every cost category, anomaly monitor and anomaly subscription, tagged or not.

func (*InMemoryBackend) LedgerEntries

func (b *InMemoryBackend) LedgerEntries(start, end string) []CostEntry

LedgerEntries returns a copy of the ledger entries with start <= date < end (YYYY-MM-DD).

func (*InMemoryBackend) LedgerSpend

func (b *InMemoryBackend) LedgerSpend(start, end string, filters map[string][]string, metric string) float64

LedgerSpend sums metric over ledger entries with start <= date < end (YYYY-MM-DD). filters uses Budgets CostFilters keys; keys the ledger does not model do not narrow.

func (*InMemoryBackend) LedgerSpendFiltered

func (b *InMemoryBackend) LedgerSpendFiltered(
	start, end string, f *SpendFilter, filters map[string][]string, metric string,
) float64

LedgerSpendFiltered is LedgerSpend narrowed further by an expression tree.

func (*InMemoryBackend) ListBackfillHistory

func (b *InMemoryBackend) ListBackfillHistory() []*BackfillJob

ListBackfillHistory returns backfill jobs sorted by RequestedAt descending. b.backfillJobs is an append-only slice (not a Table.All() map walk), so its insertion order is already stable across calls; the BackfillID tiebreak below only matters for RequestedAt's second-precision ties, making the full order deterministic for pagination cursoring.

func (*InMemoryBackend) ListCommitmentAnalyses

func (b *InMemoryBackend) ListCommitmentAnalyses(statusFilter string) []*CommitmentAnalysis

ListCommitmentAnalyses returns commitment analyses sorted by AnalysisStartedTime descending, optionally filtered to statusFilter.

Table.All() walks the table's backing map in unspecified order, and AnalysisStartedTime has only second precision, so two analyses started in the same second tie under a plain sort.Slice: the tiebreak on AnalysisID below makes the order fully deterministic across repeated calls instead of depending on map iteration order, which matters once pagination cursors on this same order (see handleListCommitmentPurchaseAnalyses).

func (*InMemoryBackend) ListCostAllocationTags

func (b *InMemoryBackend) ListCostAllocationTags(
	status, tagType string,
	tagKeys []string,
) []*CostAllocationTag

ListCostAllocationTags returns cost allocation tags, optionally filtered.

func (*InMemoryBackend) ListCostCategoryDefinitions

func (b *InMemoryBackend) ListCostCategoryDefinitions(
	maxResults int, nextPageToken, effectiveOn string,
) ([]*CostCategory, string)

ListCostCategoryDefinitions returns cost categories sorted by name with opaque pagination, narrowed to categories whose EffectiveStart is on or before effectiveOn -- see DescribeCostCategoryDefinition's EffectiveOn handling for why this backend can only honor "existed by this date", not real AWS's full historical-version lookup. Per ListCostCategoryDefinitionsInput.EffectiveOn's doc comment, an empty effectiveOn defaults to the current date rather than disabling the filter.

func (*InMemoryBackend) ListSavingsPlansGenerations added in v1.2.0

func (b *InMemoryBackend) ListSavingsPlansGenerations(
	status string,
	recommendationIDs []string,
) []*SavingsPlansGeneration

ListSavingsPlansGenerations returns generation jobs, optionally filtered by GenerationStatus and/or recommendationIDs (RecommendationId allow-list), most recently started first.

Table.All() walks the table's backing map in unspecified order, and GenerationStartedTime has only second precision, so two jobs started in the same second tie under a plain sort.Slice: the tiebreak on RecommendationID below makes the order fully deterministic across repeated calls instead of depending on map iteration order, which matters once pagination cursors on this same order (see handleListSavingsPlansPurchaseRecommendationGeneration).

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)

ListTagsForResource returns the tags for a CE resource by ARN.

func (*InMemoryBackend) MeteredEntries

func (b *InMemoryBackend) MeteredEntries(start, end string) []CostEntry

MeteredEntries returns the metered ledger rows (not the seed catalogue) with start <= date < end.

func (*InMemoryBackend) ProvideAnomalyFeedback

func (b *InMemoryBackend) ProvideAnomalyFeedback(anomalyID, feedback string) error

ProvideAnomalyFeedback persists feedback for an anomaly.

func (*InMemoryBackend) RecordCharge

func (b *InMemoryBackend) RecordCharge(e CostEntry)

RecordCharge appends an entry (for example a Tax or Support charge) to the cost ledger.

func (*InMemoryBackend) RecordUsage

func (b *InMemoryBackend) RecordUsage(u Usage)

RecordUsage adds a usage line to the ledger, split across the UTC days its time range covers.

func (*InMemoryBackend) Region

func (b *InMemoryBackend) Region() string

Region returns the region for this backend instance.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory state.

func (*InMemoryBackend) ResourceLevelData

func (b *InMemoryBackend) ResourceLevelData() bool

ResourceLevelData reports whether resource-level ledger rows are enabled.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) SetClock

func (b *InMemoryBackend) SetClock(now func() time.Time)

SetClock replaces the time source used by accrual; call before the backend is shared.

func (*InMemoryBackend) SetPriceLookup

func (b *InMemoryBackend) SetPriceLookup(p PriceLookup)

SetPriceLookup installs the price list used to cost metered usage; without one metered rows carry zero cost.

func (*InMemoryBackend) SetResourceLevelData

func (b *InMemoryBackend) SetResourceLevelData(on bool)

SetResourceLevelData turns on resource-level ledger rows (resource ids and resource tags) for metered usage.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state to JSON. It implements persistence.Persistable.

func (*InMemoryBackend) StartJanitor

func (b *InMemoryBackend) StartJanitor(ctx context.Context, interval time.Duration)

StartJanitor launches a background goroutine that evicts anomalies older than the backend's TTL. It stops when ctx is cancelled.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(resourceARN string, resourceTags map[string]string) error

TagResource adds or updates tags on a CE resource.

func (*InMemoryBackend) TagValueCost added in v1.3.1

func (b *InMemoryBackend) TagValueCost(tagKey, value, metric string) float64

TagValueCost sums the requested cost metric across ledger entries whose tag `tagKey` equals value. Used to give GetTags' SortBy a real ordering.

func (*InMemoryBackend) TaggedResources added in v1.3.1

func (b *InMemoryBackend) TaggedResources() []TaggedEntry

TaggedResources lists every cost category, anomaly monitor and anomaly subscription that carries at least one tag.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(resourceARN string, tagKeys []string) error

UntagResource removes tags from a CE resource.

func (*InMemoryBackend) UpdateAnomalyMonitor

func (b *InMemoryBackend) UpdateAnomalyMonitor(
	monARN, monitorName string,
) (*AnomalyMonitor, error)

UpdateAnomalyMonitor updates the name of an anomaly monitor.

func (*InMemoryBackend) UpdateAnomalySubscription

func (b *InMemoryBackend) UpdateAnomalySubscription(
	subARN, frequency, subscriptionName string,
	monitorARNList []string,
	subscribers []Subscriber,
	threshold float64,
	thresholdExpression *ceExpression,
) (*AnomalySubscription, error)

UpdateAnomalySubscription updates a CE anomaly subscription.

func (*InMemoryBackend) UpdateCostAllocationTagsStatus

func (b *InMemoryBackend) UpdateCostAllocationTagsStatus(
	updates []CostAllocationTagStatusEntry,
) []CostAllocationTagError

UpdateCostAllocationTagsStatus updates the Active/Inactive status of cost allocation tags. Returns a list of errors for tags that could not be updated.

func (*InMemoryBackend) UpdateCostCategoryDefinition

func (b *InMemoryBackend) UpdateCostCategoryDefinition(
	catARN, ruleVersion, defaultValue string,
	rules []CostCategoryRule,
	splitChargeRules []SplitChargeRule,
	requestedEffectiveStart string,
) (*CostCategory, error)

UpdateCostCategoryDefinition updates an existing cost category. requestedEffectiveStart, when non-empty, overrides the default "first day of the current month" -- same optional-field default as CreateCostCategoryDefinition (api_op_UpdateCostCategoryDefinition.go's EffectiveStart doc is identical to Create's: "If the date isn't provided, it's the first day of the current month").

type Meter

type Meter interface {
	RecordUsage(u Usage)
}

Meter records usage lines into the cost ledger.

type MetricValue

type MetricValue struct {
	Amount string `json:"Amount"`
	Unit   string `json:"Unit"`
}

MetricValue holds Amount+Unit for a cost metric.

type PriceLookup

type PriceLookup func(serviceCode, region string, match map[string]string, unit string) (float64, bool)

PriceLookup returns the On Demand USD price per unit for a price list product.

type Provider

type Provider struct{}

Provider implements service.Provider for the Cost Explorer (Ce) service.

func (*Provider) Init

Init initializes the Cost Explorer service.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the logical name of the provider.

type ReservationCoverageAgg

type ReservationCoverageAgg struct {
	CoverageHours           ReservationCoverageHours           `json:"CoverageHours"`
	CoverageNormalizedUnits ReservationCoverageNormalizedUnits `json:"CoverageNormalizedUnits"`
	CoverageCost            ReservationCoverageCost            `json:"CoverageCost"`
}

ReservationCoverageAgg holds RI coverage aggregates.

type ReservationCoverageByTime

type ReservationCoverageByTime struct {
	TimePeriod map[string]string      `json:"TimePeriod"`
	Total      ReservationCoverageAgg `json:"Total"`
	Groups     []any                  `json:"Groups"`
}

ReservationCoverageByTime holds RI coverage for a time period.

type ReservationCoverageCost

type ReservationCoverageCost struct {
	OnDemandCost string `json:"OnDemandCost"`
}

ReservationCoverageCost holds cost-based RI coverage.

type ReservationCoverageHours

type ReservationCoverageHours struct {
	OnDemandHours           string `json:"OnDemandHours"`
	ReservedHours           string `json:"ReservedHours"`
	TotalRunningHours       string `json:"TotalRunningHours"`
	CoverageHoursPercentage string `json:"CoverageHoursPercentage"`
}

ReservationCoverageHours holds hourly RI coverage data.

type ReservationCoverageNormalizedUnits

type ReservationCoverageNormalizedUnits struct {
	OnDemandNormalizedUnits           string `json:"OnDemandNormalizedUnits"`
	ReservedNormalizedUnits           string `json:"ReservedNormalizedUnits"`
	TotalRunningNormalizedUnits       string `json:"TotalRunningNormalizedUnits"`
	CoverageNormalizedUnitsPercentage string `json:"CoverageNormalizedUnitsPercentage"`
}

ReservationCoverageNormalizedUnits holds normalized unit coverage.

type ReservationRecommendation

type ReservationRecommendation struct {
	ServiceSpecification  map[string]any                    `json:"ServiceSpecification,omitempty"`
	RecommendationSummary map[string]string                 `json:"RecommendationSummary,omitempty"`
	AccountScope          string                            `json:"AccountScope,omitempty"`
	LookbackPeriodInDays  string                            `json:"LookbackPeriodInDays,omitempty"`
	TermInYears           string                            `json:"TermInYears,omitempty"`
	PaymentOption         string                            `json:"PaymentOption,omitempty"`
	RecommendationDetails []ReservationRecommendationDetail `json:"RecommendationDetails"`
}

ReservationRecommendation holds a single RI recommendation group.

type ReservationRecommendationDetail

type ReservationRecommendationDetail struct {
	AccountID                                 string         `json:"AccountId,omitempty"`
	InstanceDetails                           map[string]any `json:"InstanceDetails,omitempty"`
	RecommendedNumberOfInstancesToPurchase    string         `json:"RecommendedNumberOfInstancesToPurchase"`
	RecommendedNormalizedUnitsToPurchase      string         `json:"RecommendedNormalizedUnitsToPurchase"`
	MinimumNumberOfInstancesUsedPerHour       string         `json:"MinimumNumberOfInstancesUsedPerHour"`
	MinimumNormalizedUnitsUsedPerHour         string         `json:"MinimumNormalizedUnitsUsedPerHour"`
	MaximumNumberOfInstancesUsedPerHour       string         `json:"MaximumNumberOfInstancesUsedPerHour"`
	MaximumNormalizedUnitsUsedPerHour         string         `json:"MaximumNormalizedUnitsUsedPerHour"`
	AverageNumberOfInstancesUsedPerHour       string         `json:"AverageNumberOfInstancesUsedPerHour"`
	AverageNormalizedUnitsUsedPerHour         string         `json:"AverageNormalizedUnitsUsedPerHour"`
	AverageUtilization                        string         `json:"AverageUtilization"`
	EstimatedBreakEvenInMonths                string         `json:"EstimatedBreakEvenInMonths"`
	CurrencyCode                              string         `json:"CurrencyCode"`
	EstimatedMonthlySavingsAmount             string         `json:"EstimatedMonthlySavingsAmount"`
	EstimatedMonthlySavingsPercentage         string         `json:"EstimatedMonthlySavingsPercentage"`
	EstimatedMonthlyOnDemandCost              string         `json:"EstimatedMonthlyOnDemandCost"`
	EstimatedReservationCostForLookbackPeriod string         `json:"EstimatedReservationCostForLookbackPeriod"`
	UpfrontCost                               string         `json:"UpfrontCost"`
	RecurringStandardMonthlyCost              string         `json:"RecurringStandardMonthlyCost"`
}

ReservationRecommendationDetail is one RI recommendation.

type ReservationUtilizationAgg

type ReservationUtilizationAgg struct {
	UtilizationPercentage     string `json:"UtilizationPercentage"`
	PurchasedHours            string `json:"PurchasedHours"`
	TotalActualHours          string `json:"TotalActualHours"`
	UnusedHours               string `json:"UnusedHours"`
	OnDemandCostOfRIHoursUsed string `json:"OnDemandCostOfRIHoursUsed"`
	NetRISavings              string `json:"NetRISavings"`
	TotalPotentialRISavings   string `json:"TotalPotentialRISavings"`
	AmortizedUpfrontFee       string `json:"AmortizedUpfrontFee"`
	AmortizedRecurringFee     string `json:"AmortizedRecurringFee"`
	TotalAmortizedFee         string `json:"TotalAmortizedFee"`
	RICostForUnusedHours      string `json:"RICostForUnusedHours"`
	RealizedSavings           string `json:"RealizedSavings"`
	UnrealizedSavings         string `json:"UnrealizedSavings"`
}

ReservationUtilizationAgg holds RI utilization aggregates.

type ReservationUtilizationByTime

type ReservationUtilizationByTime struct {
	TimePeriod map[string]string         `json:"TimePeriod"`
	Total      ReservationUtilizationAgg `json:"Total"`
	Groups     []any                     `json:"Groups"`
}

ReservationUtilizationByTime holds RI utilization for a time period.

type ResultByTime

type ResultByTime struct {
	TimePeriod map[string]string      `json:"TimePeriod"`
	Total      map[string]MetricValue `json:"Total"`
	Groups     []CostGroup            `json:"Groups"`
	Estimated  bool                   `json:"Estimated"`
}

ResultByTime represents a single time period in GetCostAndUsage.

type RightsizingCurrentInstance

type RightsizingCurrentInstance struct {
	ResourceID   string `json:"ResourceId"`
	InstanceType string `json:"InstanceType,omitempty"`
	MonthlyCost  string `json:"MonthlyCost,omitempty"`
	CurrencyCode string `json:"CurrencyCode,omitempty"`
}

RightsizingCurrentInstance holds details about the current instance.

type RightsizingModifyDetail

type RightsizingModifyDetail struct {
	TargetInstances []RightsizingTargetInstance `json:"TargetInstances"`
}

RightsizingModifyDetail holds modification target options.

type RightsizingRecommendation

type RightsizingRecommendation struct {
	ModifyRecommendationDetail    *RightsizingModifyDetail    `json:"ModifyRecommendationDetail,omitempty"`
	TerminateRecommendationDetail *RightsizingTerminateDetail `json:"TerminateRecommendationDetail,omitempty"`
	CurrentInstance               RightsizingCurrentInstance  `json:"CurrentInstance"`
	AccountID                     string                      `json:"AccountId"`
	RightsizingType               string                      `json:"RightsizingType"`
}

RightsizingRecommendation is a single rightsizing recommendation.

type RightsizingTargetInstance

type RightsizingTargetInstance struct {
	ResourceDetails            map[string]any `json:"ResourceDetails,omitempty"`
	EstimatedMonthlyCost       string         `json:"EstimatedMonthlyCost"`
	EstimatedMonthlySavings    string         `json:"EstimatedMonthlySavings"`
	EstimatedSavingsPercentage string         `json:"EstimatedSavingsPercentage"`
	CurrencyCode               string         `json:"CurrencyCode"`
	DefaultTargetInstance      bool           `json:"DefaultTargetInstance"`
}

RightsizingTargetInstance is a recommended replacement instance.

type RightsizingTerminateDetail

type RightsizingTerminateDetail struct {
	EstimatedMonthlySavings string `json:"EstimatedMonthlySavings,omitempty"`
	CurrencyCode            string `json:"CurrencyCode,omitempty"`
}

RightsizingTerminateDetail holds termination savings estimate.

type SavingsPlansAmortized

type SavingsPlansAmortized struct {
	AmortizedRecurringCommitment string `json:"AmortizedRecurringCommitment"`
	AmortizedUpfrontCommitment   string `json:"AmortizedUpfrontCommitment"`
	TotalAmortizedCommitment     string `json:"TotalAmortizedCommitment"`
}

SavingsPlansAmortized holds amortized commitment.

type SavingsPlansGeneration added in v1.2.0

type SavingsPlansGeneration struct {
	RecommendationID         string `json:"recommendationId"`
	GenerationStatus         string `json:"generationStatus"` // PROCESSING|SUCCEEDED|FAILED
	GenerationStartedTime    string `json:"generationStartedTime"`
	GenerationCompletionTime string `json:"generationCompletionTime,omitempty"`
	EstimatedCompletionTime  string `json:"estimatedCompletionTime"`
}

SavingsPlansGeneration represents a Savings Plans purchase recommendation generation job, matching real AWS CE's GenerationSummary shape (RecommendationId, not GenerationId -- see api_op_StartSavingsPlansPurchaseRecommendationGeneration.go).

type SavingsPlansSavings

type SavingsPlansSavings struct {
	NetSavings             string `json:"NetSavings"`
	OnDemandCostEquivalent string `json:"OnDemandCostEquivalent"`
}

SavingsPlansSavings holds SP savings.

type SavingsPlansUtilizationAgg

type SavingsPlansUtilizationAgg struct {
	TotalCommitment       string `json:"TotalCommitment"`
	UsedCommitment        string `json:"UsedCommitment"`
	UnusedCommitment      string `json:"UnusedCommitment"`
	UtilizationPercentage string `json:"UtilizationPercentage"`
}

SavingsPlansUtilizationAgg holds SP utilization aggregates.

type SavingsPlansUtilizationDetail

type SavingsPlansUtilizationDetail struct {
	Attributes          map[string]string           `json:"Attributes,omitempty"`
	Utilization         *SavingsPlansUtilizationAgg `json:"Utilization,omitempty"`
	AmortizedCommitment *SavingsPlansAmortized      `json:"AmortizedCommitment,omitempty"`
	Savings             *SavingsPlansSavings        `json:"Savings,omitempty"`
	SavingsPlanARN      string                      `json:"SavingsPlanArn"`
}

SavingsPlansUtilizationDetail is a per-plan utilization entry. Utilization/AmortizedCommitment/Savings/Attributes are pointers so GetSavingsPlansUtilizationDetailsInput.DataType (real []types.SavingsPlansDataType -- ATTRIBUTES/UTILIZATION/ AMORTIZED_COMMITMENT/SAVINGS) can genuinely omit the sections a request didn't ask for, matching real AWS's per-item selective population instead of always emitting every section regardless of what was requested.

type SavingsPlansUtilizationResult

type SavingsPlansUtilizationResult struct {
	Utilization         SavingsPlansUtilizationAgg `json:"Utilization"`
	Savings             SavingsPlansSavings        `json:"Savings"`
	AmortizedCommitment SavingsPlansAmortized      `json:"AmortizedCommitment"`
}

SavingsPlansUtilizationResult is the total savings plans utilization.

type SpendFilter

type SpendFilter struct {
	Not        *SpendFilter
	Dimensions *SpendValues
	Tags       *SpendValues
	// CostCategories.Key is the cost category name.
	CostCategories *SpendValues
	// ProductAttributes.Key is a case-sensitive product attribute name.
	ProductAttributes *SpendValues
	And               []SpendFilter
	Or                []SpendFilter
}

SpendFilter is a Budgets filter expression tree evaluated against ledger entries.

type SpendValues

type SpendValues struct {
	Key          string
	Values       []string
	MatchOptions []string
}

SpendValues is one Dimensions or Tags clause of a SpendFilter.

type SplitChargeRule

type SplitChargeRule struct {
	Source  string   `json:"source"`
	Method  string   `json:"method"`
	Targets []string `json:"targets"`
}

SplitChargeRule represents a cost category split charge rule.

type Subscriber

type Subscriber struct {
	Address string `json:"address"`
	Type    string `json:"type"`
	Status  string `json:"status"`
}

Subscriber represents a CE anomaly subscription notification target.

type TaggedEntry added in v1.3.1

type TaggedEntry struct {
	Tags map[string]string
	ARN  string
}

TaggedEntry pairs a resource ARN with its tags.

type TotalImpactFilter

type TotalImpactFilter struct {
	NumericOperator string
	StartValue      float64
	EndValue        float64
}

TotalImpactFilter narrows GetAnomalies results by an anomaly's total dollar impact -- mirrors aws-sdk-go-v2/service/costexplorer/types.TotalImpactFilter.

type Usage

type Usage struct {
	Start, End time.Time
	Tags       map[string]string
	// PriceMatch selects the price list product by attribute (for example usagetype and operation).
	PriceMatch       map[string]string
	Service          string
	PriceService     string
	UsageType        string
	Operation        string
	Region           string
	AvailabilityZone string
	InstanceType     string
	ResourceID       string
	ProductFamily    string
	UsageTypeGroup   string
	// Unit is the price list unit the Quantity is expressed in (Hrs, GB-Mo, Requests, ...).
	Unit     string
	Account  string
	Quantity float64
}

Usage is one metered usage line. Cost is Quantity times the price list rate for PriceService/PriceMatch/Unit.

type UsageSource

type UsageSource func() []Usage

UsageSource returns usage the service accumulated since the previous call (for example request units).

Jump to

Keyboard shortcuts

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