Skip to content

CostCategory

Source: src/AWS/CostExplorer/CostCategory.ts

A Cost Explorer cost category — rule-based groupings that map your AWS costs into named values (e.g. team, environment, project) usable across Cost Explorer, Budgets, and CUR reports.

Cost Explorer is a global service — all calls are pinned to us-east-1 regardless of the stack region. Rules, the default value, and split-charge rules are mutable in place; changing the name replaces the category.

Categorize by linked account name

import * as CostExplorer from "alchemy/AWS/CostExplorer";
const category = yield* CostExplorer.CostCategory("Environment", {
rules: [
{
Value: "production",
Type: "REGULAR",
Rule: {
Dimensions: {
Key: "LINKED_ACCOUNT_NAME",
MatchOptions: ["ENDS_WITH"],
Values: ["-prod"],
},
},
},
],
defaultValue: "other",
});

Categorize by cost allocation tag

const category = yield* CostExplorer.CostCategory("Team", {
rules: [
{
Value: "platform",
Type: "REGULAR",
Rule: {
Tags: { Key: "team", Values: ["platform"], MatchOptions: ["EQUALS"] },
},
},
],
});