ce

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 24 Imported by: 0

README

Cost Explorer

Parity grade: A · SDK aws-sdk-go-v2/service/costexplorer@v1.63.8 · last audited 2026-07-24 (f848e87f1bce2856351a650dbbdba31bb6bbbd49)

Coverage

Metric Value
Operations audited 31 (31 ok)
Feature families 13 (13 ok)
Known gaps 1
Deferred items 2
Resource leaks clean
Known gaps
  • GetCostAndUsage/GetCostForecast/GetUsageForecast/GetDimensionValues/GetTags/GetCostCategories still lack required-field validation that the real aws-sdk-go-v2 client-side validators enforce (TimePeriod is required on all six; Metrics on GetCostAndUsage/GetCostForecast/GetUsageForecast; Dimension on GetDimensionValues already enforced). Not fixed this pass: this is a distinct, larger surface from the 7-op required-field gap closed this pass (which covered the Anomaly*/CostCategory*/Tag* families + GetAnomalies), and touches a different, larger set of existing test call sites in handler_cost_usage_test.go that omit TimePeriod/Metrics and assert 200 OK. Candidate for a dedicated follow-up pass. (bd: needs issue)
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.
  • GetCostAndUsageWithResources.ResultsByTime and ListCostCategoryResourceAssociations.CostCategoryResourceAssociations are always empty by design (see per-op notes above) -- both would need a per-resource / resource-tag inventory this emulator doesn't model anywhere else in the service. Not a disguised no-op (input-driven required-field validation now happens, and the wire shape is correct), just genuinely no backing state to report. A future pass could seed a small synthetic per-resource inventory if resource-level fidelity becomes a priority.

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.

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)
	// 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

This section is empty.

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"`
	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.

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"`
	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.

type BackfillJob

type BackfillJob struct {
	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.

type CommitmentAnalysis

type CommitmentAnalysis struct {
	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 {
	Value string `json:"value"`
}

CostCategoryRule represents a single cost category rule.

type CostEntry

type CostEntry struct {
	Tags          map[string]string `json:"tags"`
	Date          string            `json:"date"`
	Service       string            `json:"service"`
	Region        string            `json:"region"`
	UsageType     string            `json:"usageType"`
	Account       string            `json:"account"`
	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.

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) AddAnomaly

func (b *InMemoryBackend) AddAnomaly(a Anomaly)

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

func (*InMemoryBackend) CreateAnomalyMonitor

func (b *InMemoryBackend) CreateAnomalyMonitor(
	monitorName, monitorType, monitorDimension string,
	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,
	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() *CommitmentAnalysis

CreateCommitmentAnalysis starts a new commitment purchase analysis.

func (*InMemoryBackend) CreateCostCategoryDefinition

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

CreateCostCategoryDefinition creates a new cost category and returns it.

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) GetAnomalies

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

GetAnomalies returns detected anomalies, optionally filtered by monitor ARN, feedback type, and date interval. 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,
) []ResultByTime

GetCostAndUsage aggregates cost ledger entries by granularity, applying optional GroupBy.

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) GetDimensionValues

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

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

func (*InMemoryBackend) GetForecastByTime

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

GetForecastByTime returns per-bucket cost forecasts for a time range.

func (*InMemoryBackend) GetReservationCoverage

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

GetReservationCoverage returns synthetic RI coverage by time.

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) 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) GetTagValues

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

GetTagValues returns distinct values for a tag key.

func (*InMemoryBackend) ListBackfillHistory

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

ListBackfillHistory returns backfill jobs sorted by RequestedAt descending.

func (*InMemoryBackend) ListCommitmentAnalyses

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

ListCommitmentAnalyses returns all commitment analyses sorted by AnalysisStartedTime.

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 string) ([]*CostCategory, string)

ListCostCategoryDefinitions returns cost categories sorted by name with opaque pagination.

func (*InMemoryBackend) ListSavingsPlansGenerations added in v1.2.0

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

ListSavingsPlansGenerations returns generation jobs, optionally filtered by GenerationStatus, most recently started first.

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) ProvideAnomalyFeedback

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

ProvideAnomalyFeedback persists feedback for an anomaly.

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) 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) 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) 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,
) (*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,
) (*CostCategory, error)

UpdateCostCategoryDefinition updates an existing cost category.

type MetricValue

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

MetricValue holds Amount+Unit for a cost metric.

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"`
	AmortizedCommitment SavingsPlansAmortized      `json:"AmortizedCommitment"`
	Savings             SavingsPlansSavings        `json:"Savings"`
	SavingsPlanARN      string                     `json:"SavingsPlanArn"`
}

SavingsPlansUtilizationDetail is a per-plan utilization entry.

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

Jump to

Keyboard shortcuts

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