Implements the `AWSInsightsIndexService.*` JSON 1.1 surface backed by
synthesizing cost and usage from Floci's existing resource state
multiplied by the bundled AWS Pricing snapshot (#821). Covers the nine
Cost Explorer operations the FinOps tooling ecosystem most commonly
exercises:
- `GetCostAndUsage` / `GetCostAndUsageWithResources` — full
`TimePeriod`, `Granularity` (DAILY / MONTHLY / HOURLY),
`Metrics` (UnblendedCost / BlendedCost / AmortizedCost /
NetUnblendedCost / NetAmortizedCost / UsageQuantity /
NormalizedUsageAmount), `GroupBy` (DIMENSION / TAG /
COST_CATEGORY), and the recursive `Filter` expression tree
(`And` / `Or` / `Not` / `Dimensions` / `Tags` / `CostCategories`).
- `GetDimensionValues` — returns the dimension values present in the
synthesized data; honors filters and search strings.
- `GetTags` — returns tag keys / values across enumerated resources.
- `GetReservationCoverage` / `GetReservationUtilization` — zero-totalled
stubs so callers that hit these endpoints during smoke tests don't
fail on `UnknownOperationException`.
- `GetSavingsPlansCoverage` / `GetSavingsPlansUtilization` — same
stubbed shape.
- `GetCostCategories` — empty list (cost-category management is
out-of-scope for this PR).
`GROUP_BY=RECORD_TYPE` distinguishes `Usage`, `Credit`, `Tax`,
`Refund`, `DiscountedUsage`, and the four `SavingsPlan*` variants.
`Tax` / `Refund` / `DiscountedUsage` / `SavingsPlan*` are reserved for
follow-up PRs; `Credit` is emitted when
`FLOCI_SERVICES_CE_CREDIT_USD_MONTHLY > 0`, capped at the synthesized
monthly usage so net cost never goes below zero.
## Architecture
A new SPI lives in `core/common/`:
public interface ResourceUsageEnumerator {
Stream<UsageLine> enumerate(Instant start, Instant end, String region);
}
CDI auto-discovers all `@ApplicationScoped` beans implementing it.
Cost Explorer iterates `Instance<ResourceUsageEnumerator>` per request,
so adding a new Floci service with cost data is a matter of dropping a
new enumerator bean next to the service — zero changes to
`CostExplorerService`. The same enumerators will feed the upcoming CUR
and BCM Data Exports Parquet writer (#823) without duplication.
The bundled enumerators are:
- `Ec2UsageEnumerator` — `BoxUsage:<instanceType>` * hours per running
instance, priced from the Pricing snapshot.
- `S3UsageEnumerator` — `TimedStorage-ByteHrs` * GB-month per bucket,
priced from the snapshot.
- `LambdaUsageEnumerator` — catalog-only line per function (zero
quantity until invocation tracking lands in a follow-up).
- `UnpricedServicesEnumerator` — emits zero-quantity catalog rows for
the remaining ~30 Floci services so they appear in
`GetDimensionValues SERVICE` without contributing billed cost.
Each priced enumerator additionally emits a zero-quantity catalog
line so the service shows up in `GetDimensionValues SERVICE` even
when no resources exist.
## Tests
`CostExplorerIntegrationTest` covers all nine operations via
RestAssured wire-format assertions: granularity bucketing,
filter-expression evaluation, group-by combinations, dimension and
tag listings, RI / SP stubs, validation errors. 20 tests, all green.
The full Floci test suite stays green with the additions
(4030 tests run, 0 failures, 0 errors, excluding the pre-existing
local-env flakes documented during PR #821).
Refs: https://github.com/orgs/floci-io/discussions/791
Refs: https://github.com/floci-io/floci/issues/822