CostFormation Templates

Start organizing your costs in minutes with ready-to-use YAML templates. Each template below is a complete, working Dimension definition. Copy it, replace the example values with your own, and publish. For syntax details on any property, see the CostFormation Reference. For concepts like rule ordering, transforms, and sources, see How to Build a Dimension.

TemplateWhat it solves
Merge multiple tag values that mean the same thingNormalize messy tag values into clean element names
Some costs are in dedicated accounts, others are taggedMatch by account ID with a tag-based fallback
The same tag exists under different keys and casingNormalize inconsistent tag keys and casing into a single Dimension
Costs must match multiple criteriaMatch costs by two or more attributes using And conditions
Split shared costs by existing spendProportionally split shared costs across groups
Allocate unattributed spend across known groupsSpread costs with no Dimension value across costs that do

Merge multiple tag values that mean the same thing

Use Group rules to map messy tag values to clean element names, with a trailing GroupBy to catch everything else.

Dimensions:
  Team:
    Name: Team
    Rules:
      - Type: Group
        Name: Customer Service
        Conditions:
          - Source: Tag:Team
            Equals:
              - custservice
              - cs
              - customer-service
      - Type: GroupBy
        Source: Tag:Team

How this works

  1. CloudZero checks each cost's Tag:Team value.
  2. If the value equals custservice, cs, or customer-service, the cost goes into the Customer Service element and evaluation stops for that cost.
  3. If it does not match, the cost falls through to the GroupBy, which creates elements from the exact Tag:Team values (like Security or Development).

Some costs are in dedicated accounts, others are tagged

Use Group rules to match known account IDs, with a trailing GroupBy to pick up anything else from a tag.

Dimensions:
  Environment:
    Name: Environment
    Source: Account
    Rules:
      - Type: Group
        Name: Production
        Conditions:
          - Equals:
              - 012345678901
              - 109876543210
      - Type: Group
        Name: Development
        Conditions:
          - Equals: 234567890123
      - Type: GroupBy
        Source: Tag:Environment

How this works

  1. CloudZero checks each cost's account ID against the Production rule. If it matches, the cost goes into Production and evaluation stops for that cost.
  2. If it does not match, it checks the Development rule the same way. If that matches, evaluation stops.
  3. Any remaining spend falls through to the GroupBy, which creates elements from the exact values in the Environment tag.

The same tag exists under different keys and casing

Use a transform to normalize casing and Group rules for known values, with a trailing GroupBy that checks multiple tag keys for anything left over.

Dimensions:
  Environment:
    Name: Environment
    Source: Tag:Environment
    Transforms:
      - Type: Lower
    Rules:
      - Type: Group
        Name: Pre-Production
        Conditions:
          - Contains:
              - pre-prod
              - preprod
      - Type: Group
        Name: Production
        Conditions:
          - Contains:
              - prod
              - prd
      - Type: Group
        Name: Development
        Conditions:
          - Contains:
              - dev
              - dvl
      - Type: GroupBy
        Sources:
          - Tag:Env
          - Tag:Environment
          - Tag:environment
        CoalesceSources: true

How this works

  1. CloudZero looks at each cost's Tag:Environment value.
  2. The Lower transform converts all values to lowercase for consistent matching.
  3. The Group rules check the lowercased value top to bottom. Pre-Production is listed first because Contains: prod would also match pre-prod. By checking pre-prod and preprod first, those costs are captured correctly before the Production rule runs. Costs that do not match Pre-Production are then checked against Production, and if they do not match there, against Development.
  4. Any remaining spend falls through to the GroupBy, which defines its own sources and does not inherit the Lower transform. It checks Tag:Env, Tag:Environment, and Tag:environment in that order. The first tag key with a value determines the element name for that cost, using the original casing from the tag.

Costs must match multiple criteria

Use And conditions to match costs by multiple attributes, like a specific account and a specific tag value.

Dimensions:
  Application:
    Name: Application
    Rules:
      - Type: Group
        Name: Payments
        Conditions:
          - And:
              - Source: Account
                Equals: 012345678901
              - Source: Tag:Application
                Equals: payments
      - Type: Group
        Name: Billing
        Conditions:
          - And:
              - Source: Account
                Equals: 012345678901
              - Source: Tag:Application
                Equals: billing
      - Type: GroupBy
        Source: Tag:Application
        Conditions:
          - Source: Account
            Equals: 012345678901

How this works

  1. CloudZero checks each cost against the first rule. If the account is 012345678901 AND the application tag is payments, the cost goes into Payments and evaluation stops for that cost.
  2. If not, it checks the second rule. Same account AND billing tag goes into Billing and evaluation stops.
  3. Any remaining spend in that account that has an application tag falls through to the GroupBy, which creates elements from the tag values.
ℹ️

Conditions within a rule are treated as Or by default. You only need And when every condition must be true for the same cost. You can use Or explicitly, but it is unnecessary since it is the default behavior.

Split shared costs by existing spend (proportional allocation)

Use an Allocation Dimension with Proportional rules to split shared costs across groups based on each group's existing spend.

Dimensions:
  SharedDatabaseCosts:
    Name: Shared Database Costs
    Type: Allocation
    Hide: true
    AllocateByRules:
      AllocationMethod: Proportional
      SpendToAllocate:
        Conditions:
          - Source: Service
            Equals: Amazon RDS
      AcrossElements:
        Rules:
          - Type: GroupBy
            Source: Tag:Application
            Conditions:
              - Source: Tag:Application
                HasValue: true

How this works

  1. AllocateByRules with Proportional indicates CloudZero will proportionally split costs.
  2. SpendToAllocate identifies the costs to split: all RDS spend.
  3. AcrossElements groups by the Application tag where it has a non-null value, creating elements like Payments, Billing, and Auth.
  4. CloudZero proportionally distributes the RDS spend across those identified elements based on each one's share of existing cloud spend.
  5. Hide: true keeps this Dimension as a building block. Add it to a visible Grouping Dimension using a GroupBy rule to combine it with your dedicated costs.

Allocate unattributed spend across known groups

Use a hidden Allocation Dimension to spread unattributed spend proportionally across costs that do have a value, then join the results into a visible Grouping Dimension.

Dimensions:
  EnvironmentAllocation:
    Name: Environment Allocation
    Type: Allocation
    Hide: true
    AllocateByRules:
      AllocationMethod: Proportional
      SpendToAllocate:
        Conditions:
          - Source: User:Defined:Environment
            HasValue: false
      AcrossElements:
        Rules:
          - Type: GroupBy
            Source: User:Defined:Environment
            Conditions:
              - HasValue: true

  EnvironmentJoined:
    Name: Environment
    Rules:
      - Type: GroupBy
        Sources:
          - User:Defined:EnvironmentAllocation
          - User:Defined:Environment
        CoalesceSources: true
ℹ️

HasValue: false only matches costs under Not In Dimension. If the source Dimension has a Default Value (like Other), those costs are considered an element and will show as having a value.

How this works

  1. EnvironmentAllocation is the hidden Allocation Dimension. SpendToAllocate targets all costs where the Environment Dimension has no value (HasValue: false).
  2. AcrossElements groups by the same Environment Dimension, but only where it has a value (HasValue: true), creating elements like Production, Development, and Staging.
  3. CloudZero proportionally distributes the unattributed spend across those elements based on each one's share of existing spend.
  4. EnvironmentJoined is the visible Dimension users interact with. Its GroupBy checks the Allocation Dimension first, then the original Environment Dimension, using CoalesceSources: true to take the first value it finds. This merges the allocated and attributed costs into a single Dimension.
ℹ️

Have questions or feedback? Reach out to your account manager.