Skip to content

feat: add Cost Explorer (ce:*) service #822

@ShubhamDX

Description

@ShubhamDX

Tracking issue for the Cost Explorer (ce:*) service — PR 2 of 3 from the scope discussion in #791.

Blocked by the AWS Pricing API service in #821 (cost synthesis consumes the Pricing snapshot).

Scope

AWS Cost Explorer API, JSON 1.1, X-Amz-Target: AWSInsightsIndexService.<Action> (signing name ce, endpoint prefix ce).

Operations:

  • GetCostAndUsage — full support for TimePeriod, Granularity (DAILY / MONTHLY / HOURLY), Metrics (UnblendedCost, BlendedCost, AmortizedCost, NetUnblendedCost, NetAmortizedCost, UsageQuantity, NormalizedUsageAmount), GroupBy, and the recursive Filter expression tree (And / Or / Not / Dimensions / Tags / CostCategories).
  • GetCostAndUsageWithResources — same shape, includes resource-level breakdown from Floci's existing resource state.
  • GetDimensionValues — returns dimension values available in Floci's synthesized data.
  • GetTags — returns tag keys/values across Floci resource state.
  • GetReservationCoverage + GetReservationUtilization — stubs backed by static "no RI" responses unless an RI fixture is supplied.
  • GetSavingsPlansCoverage + GetSavingsPlansUtilization — same stub approach.
  • GetCostCategories + GetCostCategoryDefinition — minimal definitions list; empty if none configured.

Approach

Cost data is synthesized on each request from:

  1. Floci's existing resource state (S3 buckets, EC2 instances, Lambda functions, …) at the requested TimePeriod.
  2. The Pricing snapshot from feat(pricing): add AWS Price List Service support #821 (rate per (serviceCode, regionCode, usageType, …)).
  3. The GroupBy / Filter expression applied after synthesis.

GroupBy=RECORD_TYPE must distinguish Usage, Credit, Tax, Refund, DiscountedUsage, SavingsPlanCoveredUsage, SavingsPlanNegation, SavingsPlanUpfrontFee, SavingsPlanRecurringFee — essential for testing any code path that separates gross usage from net billable outlay (credit-offset accounts, spend-limit checks, invoice-reconciliation code).

A single config knob for synthetic-credit injection (neutral name, matches Floci's existing FLOCI_SERVICES_<SVC>_* convention):

FLOCI_SERVICES_CE_CREDIT_USD_MONTHLY

emits a monthly Credit line item that offsets min(credit, usage) — gives downstream tools a deterministic way to exercise credit-offset logic without synthesizing their own fixtures.

Size estimate

~1000-1500 LOC Java + docs/services/ce.md.

Non-goals

  • Anomaly detection (split into a separate PR; ce:GetAnomalies etc.).
  • CUR emission (covered by PR 3, see separate tracking issue).
  • Right-sizing recommendations (ce:GetRightsizingRecommendation) — out of scope for initial landing.

Open question for maintainers

The cost-synthesis path is a new shape in the repo (every other service either reads persisted state directly or returns a stub). Happy to go either way on:

  1. A single concrete CostSynthesisBackend implementation with well-defined extension points, or
  2. A formal SPI that downstream users can swap out entirely.

Option 1 keeps things minimal; option 2 is more future-proof if you anticipate users wanting non-trivial billing models (EDP discounts, custom Savings Plan math). Leaning toward option 1 unless you have a strong preference.

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions