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.
| Template | What it solves |
|---|---|
| Merge multiple tag values that mean the same thing | Normalize messy tag values into clean element names |
| Some costs are in dedicated accounts, others are tagged | Match by account ID with a tag-based fallback |
| The same tag exists under different keys and casing | Normalize inconsistent tag keys and casing into a single Dimension |
| Costs must match multiple criteria | Match costs by two or more attributes using And conditions |
| Split shared costs by existing spend | Proportionally split shared costs across groups |
| Allocate unattributed spend across known groups | Spread 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:TeamHow this works
- CloudZero checks each cost's
Tag:Teamvalue. - If the value equals
custservice,cs, orcustomer-service, the cost goes into theCustomer Serviceelement and evaluation stops for that cost. - If it does not match, the cost falls through to the
GroupBy, which creates elements from the exactTag:Teamvalues (likeSecurityorDevelopment).
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:EnvironmentHow this works
- CloudZero checks each cost's account ID against the
Productionrule. If it matches, the cost goes intoProductionand evaluation stops for that cost. - If it does not match, it checks the
Developmentrule the same way. If that matches, evaluation stops. - Any remaining spend falls through to the
GroupBy, which creates elements from the exact values in theEnvironmenttag.
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: trueHow this works
- CloudZero looks at each cost's
Tag:Environmentvalue. - The
Lowertransform converts all values to lowercase for consistent matching. - The
Grouprules check the lowercased value top to bottom.Pre-Productionis listed first becauseContains: prodwould also matchpre-prod. By checkingpre-prodandpreprodfirst, those costs are captured correctly before theProductionrule runs. Costs that do not matchPre-Productionare then checked againstProduction, and if they do not match there, againstDevelopment. - Any remaining spend falls through to the
GroupBy, which defines its own sources and does not inherit theLowertransform. It checksTag:Env,Tag:Environment, andTag:environmentin 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: 012345678901How this works
- CloudZero checks each cost against the first rule. If the account is
012345678901AND the application tag ispayments, the cost goes intoPaymentsand evaluation stops for that cost. - If not, it checks the second rule. Same account AND
billingtag goes intoBillingand evaluation stops. - 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
Orby default. You only needAndwhen every condition must be true for the same cost. You can useOrexplicitly, 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: trueHow this works
AllocateByRuleswithProportionalindicates CloudZero will proportionally split costs.SpendToAllocateidentifies the costs to split: all RDS spend.AcrossElementsgroups by theApplicationtag where it has a non-null value, creating elements likePayments,Billing, andAuth.- CloudZero proportionally distributes the RDS spend across those identified elements based on each one's share of existing cloud spend.
Hide: truekeeps 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: falseonly matches costs under Not In Dimension. If the source Dimension has a Default Value (likeOther), those costs are considered an element and will show as having a value.
How this works
EnvironmentAllocationis the hidden Allocation Dimension.SpendToAllocatetargets all costs where theEnvironmentDimension has no value (HasValue: false).AcrossElementsgroups by the sameEnvironmentDimension, but only where it has a value (HasValue: true), creating elements likeProduction,Development, andStaging.- CloudZero proportionally distributes the unattributed spend across those elements based on each one's share of existing spend.
EnvironmentJoinedis the visible Dimension users interact with. ItsGroupBychecks the Allocation Dimension first, then the original Environment Dimension, usingCoalesceSources: trueto 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.
Updated 18 days ago
