Skip to main content

Cloud Infrastructure Billing

How to implement multi-resource cloud billing (VMs, Load Balancers, network traffic, Object Storage) using Billerang.

Business Model

ResourcePricing ModelExample
VM InstancesHourly usage, matrix by instance type + regionm5.large us-east: $0.096/hr
Load BalancerMonthly recurring$18.00/month
Egress TrafficTiered by volume0-10TB: $0.09/GB
Object StorageUsage by storage classStandard: $0.023/GB-month
RetrievalUsage by storage classGlacier: $0.030/GB

Catalog Structure

Step-by-Step Implementation

1. Compute -- VM Instance Hours

POST /api/rest/v2/chargeTemplate/UC_VM_HOURS
{
"chargeType": "USAGE",
"description": "VM compute hours",
"invoiceSubCategoryCode": "ISC_COMPUTE",
"taxClassCode": "TAX_CLOUD_SERVICES",
"filterExpression": "#{edr.parameter1 != null && edr.parameter2 != null}",
"priority": 1,
"inputUnitOfMeasureCode": "HOUR",
"ratingUnitOfMeasureCode": "HOUR",
"pricing": {
"mode": "MATRIX",
"baseCurrency": "USD",
"dimensions": [
{ "code": "INSTANCE_TYPE", "type": "String", "label": "Instance Type", "position": 1 },
{ "code": "REGION", "type": "String", "label": "Region", "position": 2 }
],
"rows": [
{
"priority": 1,
"values": [
{ "dimensionCode": "INSTANCE_TYPE", "stringValue": "m5.large" },
{ "dimensionCode": "REGION", "stringValue": "us-east-1" }
],
"price": 0.096
},
{
"priority": 2,
"values": [
{ "dimensionCode": "INSTANCE_TYPE", "stringValue": "m5.large" },
{ "dimensionCode": "REGION", "stringValue": "eu-west-1" }
],
"price": 0.107
},
{
"priority": 3,
"values": [
{ "dimensionCode": "INSTANCE_TYPE", "stringValue": "m5.xlarge" },
{ "dimensionCode": "REGION", "stringValue": "us-east-1" }
],
"price": 0.192
},
{
"priority": 4,
"values": [
{ "dimensionCode": "INSTANCE_TYPE", "stringValue": "m5.xlarge" },
{ "dimensionCode": "REGION", "stringValue": "eu-west-1" }
],
"price": 0.214
},
{
"priority": 5,
"values": [
{ "dimensionCode": "INSTANCE_TYPE", "stringValue": "c5.2xlarge" },
{ "dimensionCode": "REGION", "stringValue": "us-east-1" }
],
"price": 0.340
},
{
"priority": 99,
"description": "Default VM pricing",
"price": 0.200
}
],
"autoPublish": true
}
}

2. Network -- Load Balancer + Egress Traffic

# Load Balancer base fee
POST /api/rest/v2/chargeTemplate/RC_LB_BASE
{
"chargeType": "RECURRING",
"description": "Load Balancer monthly fee",
"calendar": "MONTHLY",
"applyInAdvance": true,
"invoiceSubCategoryCode": "ISC_NETWORK",
"pricing": {
"mode": "FLAT",
"baseCurrency": "USD",
"price": 18.00,
"autoPublish": true
}
}

# Internal traffic (free)
POST /api/rest/v2/chargeTemplate/UC_INTERNAL
{
"chargeType": "USAGE",
"description": "Internal network traffic (free)",
"invoiceSubCategoryCode": "ISC_NETWORK",
"filterExpression": "#{edr.parameter1 == 'INTERNAL'}",
"priority": 1,
"pricing": {
"mode": "FLAT",
"baseCurrency": "USD",
"price": 0.00,
"autoPublish": true
}
}

# Egress traffic (tiered)
POST /api/rest/v2/chargeTemplate/UC_EGRESS
{
"chargeType": "USAGE",
"description": "Egress network traffic",
"invoiceSubCategoryCode": "ISC_NETWORK",
"filterExpression": "#{edr.parameter1 == 'EGRESS'}",
"priority": 2,
"inputUnitOfMeasureCode": "GB",
"ratingUnitOfMeasureCode": "GB",
"pricing": {
"mode": "TIERED",
"baseCurrency": "USD",
"applicationLevel": "BILLING_PERIOD",
"tiers": [
{ "from": 0, "to": 10240, "rate": 0.090 },
{ "from": 10241, "to": 51200, "rate": 0.085 },
{ "from": 51201, "to": 153600, "rate": 0.070 },
{ "from": 153601, "to": null, "rate": 0.050 }
],
"autoPublish": true
}
}

Note: applicationLevel: "BILLING_PERIOD" means tiers are calculated over the entire month's aggregate, not per-CDR. This is critical for volume-based discounts.

3. Storage -- GB-Months + Retrieval

# Storage charge (by storage class)
POST /api/rest/v2/chargeTemplate/UC_STORAGE_GB
{
"chargeType": "USAGE",
"description": "Object storage GB-months",
"invoiceSubCategoryCode": "ISC_STORAGE",
"filterExpression": "#{edr.parameter1 != null && edr.parameter2 == 'STORAGE'}",
"priority": 1,
"inputUnitOfMeasureCode": "GB_MONTH",
"ratingUnitOfMeasureCode": "GB_MONTH",
"pricing": {
"mode": "MATRIX",
"baseCurrency": "USD",
"dimensions": [
{ "code": "STORAGE_CLASS", "type": "String", "label": "Storage Class" }
],
"rows": [
{ "priority": 1, "values": [{ "dimensionCode": "STORAGE_CLASS", "stringValue": "STANDARD" }], "price": 0.023 },
{ "priority": 2, "values": [{ "dimensionCode": "STORAGE_CLASS", "stringValue": "INFREQUENT_ACCESS" }], "price": 0.0125 },
{ "priority": 3, "values": [{ "dimensionCode": "STORAGE_CLASS", "stringValue": "GLACIER" }], "price": 0.004 },
{ "priority": 99, "description": "Default", "price": 0.023 }
],
"autoPublish": true
}
}

# Retrieval charge (by storage class)
POST /api/rest/v2/chargeTemplate/UC_RETRIEVAL
{
"chargeType": "USAGE",
"description": "Data retrieval charges",
"invoiceSubCategoryCode": "ISC_STORAGE",
"filterExpression": "#{edr.parameter1 != null && edr.parameter2 == 'RETRIEVAL'}",
"priority": 2,
"inputUnitOfMeasureCode": "GB",
"ratingUnitOfMeasureCode": "GB",
"pricing": {
"mode": "MATRIX",
"baseCurrency": "USD",
"dimensions": [
{ "code": "STORAGE_CLASS", "type": "String", "label": "Storage Class" }
],
"rows": [
{ "priority": 1, "values": [{ "dimensionCode": "STORAGE_CLASS", "stringValue": "STANDARD" }], "price": 0.000 },
{ "priority": 2, "values": [{ "dimensionCode": "STORAGE_CLASS", "stringValue": "INFREQUENT_ACCESS" }], "price": 0.010 },
{ "priority": 3, "values": [{ "dimensionCode": "STORAGE_CLASS", "stringValue": "GLACIER" }], "price": 0.030 },
{ "priority": 99, "description": "Default", "price": 0.010 }
],
"autoPublish": true
}
}

4. Create Products and Offers

# Compute
POST /api/rest/catalog/products
{ "code": "VM_INSTANCE", "description": "Virtual Machine Instance" }
POST /api/rest/catalog/products/VM_INSTANCE/addCharges
{ "productCharges": [{ "chargeTemplateCode": "UC_VM_HOURS" }] }

POST /api/rest/catalog/offerTemplate/createOrUpdate
{
"code": "CLOUD_COMPUTE",
"description": "Cloud Compute Instances",
"offerProductTemplates": [{ "productTemplate": { "code": "VM_INSTANCE" } }]
}

# Network
POST /api/rest/catalog/products
{ "code": "LOAD_BALANCER", "description": "Application Load Balancer" }
POST /api/rest/catalog/products/LOAD_BALANCER/addCharges
{ "productCharges": [{ "chargeTemplateCode": "RC_LB_BASE" }] }

POST /api/rest/catalog/products
{ "code": "NETWORK_TRAFFIC", "description": "Network Traffic" }
POST /api/rest/catalog/products/NETWORK_TRAFFIC/addCharges
{ "productCharges": [
{ "chargeTemplateCode": "UC_INTERNAL" },
{ "chargeTemplateCode": "UC_EGRESS" }
] }

POST /api/rest/catalog/offerTemplate/createOrUpdate
{
"code": "CLOUD_NETWORK",
"description": "Cloud Networking",
"offerProductTemplates": [
{ "productTemplate": { "code": "LOAD_BALANCER" } },
{ "productTemplate": { "code": "NETWORK_TRAFFIC" } }
]
}

# Storage
POST /api/rest/catalog/products
{ "code": "OBJECT_STORAGE", "description": "Object Storage" }
POST /api/rest/catalog/products/OBJECT_STORAGE/addCharges
{ "productCharges": [
{ "chargeTemplateCode": "UC_STORAGE_GB" },
{ "chargeTemplateCode": "UC_RETRIEVAL" }
] }

POST /api/rest/catalog/offerTemplate/createOrUpdate
{
"code": "CLOUD_STORAGE",
"description": "Cloud Object Storage",
"offerProductTemplates": [{ "productTemplate": { "code": "OBJECT_STORAGE" } }]
}

5. Multi-Subscription Order

A cloud customer typically subscribes to multiple offers:

POST /api/rest/orderManagement/commercialOrders
{
"code": "ORD_CLOUD_ACME",
"billingAccountCode": "BA_ACME_CLOUD",
"orderDate": "2026-04-01T00:00:00Z",
"orderItems": [
{
"offerCode": "CLOUD_COMPUTE",
"subscriptionCode": "SUB_COMPUTE_001",
"action": "SUBSCRIBE",
"products": [{ "productCode": "VM_INSTANCE", "quantity": 1 }]
},
{
"offerCode": "CLOUD_NETWORK",
"subscriptionCode": "SUB_NETWORK_001",
"action": "SUBSCRIBE",
"products": [
{ "productCode": "LOAD_BALANCER", "quantity": 2 },
{ "productCode": "NETWORK_TRAFFIC", "quantity": 1 }
]
},
{
"offerCode": "CLOUD_STORAGE",
"subscriptionCode": "SUB_STORAGE_001",
"action": "SUBSCRIBE",
"products": [{ "productCode": "OBJECT_STORAGE", "quantity": 1 }]
}
]
}

Metering Patterns

Hourly VM Metering

Infrastructure agent submits CDRs every hour:

POST /api/rest/billing/mediation/registerCdrList
{
"cdrs": [
"SUB_COMPUTE_001;2026-04-01T01:00:00Z;m5.large;us-east-1;1",
"SUB_COMPUTE_001;2026-04-01T01:00:00Z;c5.2xlarge;us-east-1;1",
"SUB_COMPUTE_001;2026-04-01T02:00:00Z;m5.large;us-east-1;1",
"SUB_COMPUTE_001;2026-04-01T02:00:00Z;c5.2xlarge;us-east-1;1"
]
}

CDR format: subscriptionCode;eventDate;parameter1(instanceType);parameter2(region);quantity

Daily Storage Metering

Daily job calculates GB-months:

POST /api/rest/billing/mediation/registerCdrList
{
"cdrs": [
"SUB_STORAGE_001;2026-04-01T00:00:00Z;STANDARD;STORAGE;16.67",
"SUB_STORAGE_001;2026-04-01T00:00:00Z;GLACIER;STORAGE;66.67",
"SUB_STORAGE_001;2026-04-01T00:00:00Z;STANDARD;RETRIEVAL;5.0",
"SUB_STORAGE_001;2026-04-01T00:00:00Z;GLACIER;RETRIEVAL;2.0"
]
}

GB-month calculation: daily_average_gb * (1/30)

Network Traffic Metering

POST /api/rest/billing/mediation/registerCdrList
{
"cdrs": [
"SUB_NETWORK_001;2026-04-01T00:00:00Z;EGRESS;;150.5",
"SUB_NETWORK_001;2026-04-01T00:00:00Z;INTERNAL;;500.0"
]
}

Month-End Invoice

═══════════════════════════════════════════════════════
Invoice: ACME Cloud Inc. Period: April 2026
═══════════════════════════════════════════════════════

COMPUTE
VM Instance (m5.large, us-east-1)
720 hours * $0.096/hr $69.12
VM Instance (c5.2xlarge, us-east-1)
200 hours * $0.340/hr $68.00
───────────────────────────────────────────────────────
Compute subtotal $137.12

NETWORK
Load Balancer x2 ($18.00/mo each) $36.00
Egress Traffic
First 10TB (10,240 GB * $0.090) $921.60
Next 5TB (5,120 GB * $0.085) $435.20
Internal Traffic (free) $0.00
───────────────────────────────────────────────────────
Network subtotal $1,392.80

STORAGE
Standard (500 GB-months * $0.023) $11.50
Glacier (2,000 GB-months * $0.004) $8.00
Retrieval - Standard (free) $0.00
Retrieval - Glacier (50 GB * $0.030) $1.50
───────────────────────────────────────────────────────
Storage subtotal $21.00

═══════════════════════════════════════════════════════
TOTAL (excl. tax) $1,550.92
═══════════════════════════════════════════════════════

Key Billerang Features Used

FeaturePurpose
Matrix pricingInstance type x region pricing
Tiered pricingVolume-based egress discounts
applicationLevel: BILLING_PERIODAggregate tiers over monthly total
Multiple offersSeparate compute/network/storage subscriptions
Batch CDRHigh-volume hourly/daily metering
filterExpressionRoute CDRs to correct charge (EGRESS vs INTERNAL)
Multi-charge productStorage + Retrieval under one product
Unit of measureHours, GB, GB-months with conversion

Reserved Instances (Advanced)

For committed usage discounts, create a separate offer with discounted PPM:

POST /api/rest/catalog/offerTemplate/createOrUpdate
{
"code": "CLOUD_COMPUTE_RESERVED",
"description": "Reserved Instances (1-year commitment)",
"offerProductTemplates": [{ "productTemplate": { "code": "VM_INSTANCE" } }]
}

# Offer-scoped PPM with 40% discount
POST /api/rest/catalog/pricePlanMatrix/createOrUpdate
{
"code": "PP_VM_RESERVED",
"eventCode": "UC_VM_HOURS",
"offerTemplateCode": "CLOUD_COMPUTE_RESERVED",
"priority": 1,
"pricePlanMatrixVersions": [{
"status": "PUBLISHED",
"isMatrix": true,
"columns": [
{ "code": "INSTANCE_TYPE", "type": "String" },
{ "code": "REGION", "type": "String" }
],
"lines": [
{ "priority": 1, "values": ["m5.large", "us-east-1"], "price": 0.058 },
{ "priority": 2, "values": ["c5.2xlarge", "us-east-1"], "price": 0.204 }
]
}]
}