mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fee688bd051a5bde4e2e8a4d5e0f5d75c7ffe00a
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6d36f66e5f |
feat(cur, bcm-data-exports): add Cost and Usage Reports + BCM Data Exports (#850)
Implements PR 3 of the 3-PR billing-API scope discussed in #791. Adds two service surfaces that share one underlying export pipeline: - `cur:*` — legacy Cost and Usage Reports management plane, target prefix `AWSOrigamiServiceGatewayService.*`. - `bcm-data-exports:*` — modern Billing and Cost Management Data Exports management plane, target prefix `AWSBillingAndCostManagementDataExports.*`. Both run as JSON 1.1 services dispatched through the existing `AwsJson11Controller`. ## Operations CUR (7): - `PutReportDefinition`, `ModifyReportDefinition`, `DescribeReportDefinitions`, `DeleteReportDefinition` - `TagResource` / `UntagResource` / `ListTagsForResource` (stubs) BCM Data Exports (7): - `CreateExport`, `GetExport`, `ListExports`, `UpdateExport`, `DeleteExport` - `ListExecutions`, `GetExecution` AWS-shaped error codes throughout: `DuplicateReportNameException`, `ReportLimitReachedException`, `ReportNotFoundException`, `ResourceNotFoundException`, `ValidationException`, `UnknownOperationException`. Storage keys are account-scoped (`<accountId>::<region>::<reportName>` for CUR; `<accountId>::<exportArn>` and `<accountId>::<exportArn>::<executionId>` for BCM) so both services participate in Floci's per-account isolation. ## Parquet emission The same `ResourceUsageEnumerator` SPI introduced in #832 (Cost Explorer) backs the Parquet artifact: 1. `EmissionEngine` collects `UsageLine` rows from every `@ApplicationScoped` enumerator bean. 2. `FocusRowProjector` projects them into FOCUS 1.2 / CUR 2.0 column shape, reusing #821's bundled Pricing snapshot for unit prices. 3. Rows are staged as newline-delimited JSON in `s3://floci-cur-staging/...` via Floci's S3 service — escape-safe for tags, descriptions, and resource identifiers. 4. The `floci-duck` sidecar runs `COPY (SELECT * FROM read_json_auto('s3://...')) TO 's3://...' (FORMAT PARQUET)` so Parquet writes happen inside DuckDB, not in the Java process. This avoids pulling Apache Parquet / Hadoop / Avro into Floci's classpath and keeps the native binary footprint unchanged. 5. Staging objects are removed in a best-effort `finally` block; each run carries a fresh `runId` (UUID) in both staging and destination keys so concurrent emissions cannot clobber each other. The emission engine is shared between CUR and BCM, but the management planes are otherwise independent — they each own their own validation, storage, and JSON dispatch. ## Run modes `FLOCI_SERVICES_CUR_EMIT_MODE` and `FLOCI_SERVICES_BCM_DATA_EXPORTS_EMIT_MODE`: - `synchronous` (default): emit on every report/export mutation - `daily`: emit once per 24h via a CUR-owned single-thread `ScheduledExecutorService` — separate from the EventBridge Scheduler dispatcher, so internal billing exports do not surface as user-visible Scheduler resources. - `off`: management plane only Emission failures never roll back the management mutation. Failures surface as `ReportStatus.LastStatus = ERROR` on CUR and `Execution.ExecutionStatus.StatusCode = DELIVERY_FAILURE` on BCM. ## Tests 42 new tests across 5 classes: - `CurIntegrationTest` (11) — full CRUD on report definitions, duplicate / not-found / validation paths - `BcmDataExportsIntegrationTest` (16) — full CRUD on exports + executions, all validation paths - `FocusRowProjectorTest` (9) — pure-unit projection: usage rows, USD-denominated record types (Credit / Refund / Tax), missing resource id, tags JSON, billing-period anchoring, region+account flow-through, rate cache reuse - `ParquetEmitterIntegrationTest` (3) — DuckDB readback, staging cleanup, concurrent run isolation - `CurEmissionIntegrationTest` (3) — end-to-end: PutReportDefinition -> emit -> Parquet readable through DuckDB; ReportStatus updates; CreateExport produces an execution record Full Floci suite stays green (4194/4194, excluding the pre-existing local-env flakes documented during PR #821 / #832 and the two duck-required tests added here that need the `floci-duck` sidecar and a fixed Floci HTTP port to verify cross-container S3 access). ## Documentation - `docs/services/cur.md` — operations, validation rules, emission pipeline, configuration, examples. - `docs/services/bcm-data-exports.md` — operations, validation, execution lifecycle, configuration, examples. - README service table updated with rows for both, plus a note that CUR / BCM Data Exports share one Parquet engine. Refs: https://github.com/orgs/floci-io/discussions/791 Refs: #823 Builds on: #821, #832 |