Skip to content

GetCostAndUsage

Source: src/AWS/CostExplorer/GetCostAndUsage.ts

Runtime binding for ce:GetCostAndUsage.

Query cost and usage metrics (UnblendedCost, UsageQuantity, …) filtered and grouped by dimension over a time range — the core Cost Explorer query. Provide the implementation with Effect.provide(AWS.CostExplorer.GetCostAndUsageHttp).

// init — account-level binding takes no resource
const getCostAndUsage = yield* AWS.CostExplorer.GetCostAndUsage();
// runtime
const result = yield* getCostAndUsage({
TimePeriod: { Start: "2026-06-01", End: "2026-07-01" },
Granularity: "MONTHLY",
Metrics: ["UnblendedCost"],
});
const total = result.ResultsByTime?.[0]?.Total?.UnblendedCost?.Amount;