Usage File Format
Some cloud resources have variable pricing that depends on actual usage rather than provisioned capacity. Examples include Lambda invocations, S3 storage and requests, data transfer, and DynamoDB read/write capacity. C3X uses usage files to model these costs accurately.
Without a usage file, C3X estimates variable-cost resources at zero usage (showing $0) and marks them with a note. By providing expected monthly usage values, you get a complete picture of your infrastructure costs.
File Format
Usage files are YAML files named c3x-usage.yml by default. Each top-level key is a Terraform resource address, and its children are the usage parameters for that resource type.
version: 0.1
resource_usage:
aws_instance.web:
operating_system: linux
reserved_instance_type: standard
reserved_instance_term: 1_year
reserved_instance_payment_option: partial_upfront
monthly_hrs: 730
aws_lambda_function.api:
monthly_requests: 10000000 # 10 million requests/month
request_duration_ms: 150 # average 150ms per invocation
memory_mb: 512 # allocated memory
aws_s3_bucket.assets:
storage_gb: 500 # 500 GB stored
monthly_tier_1_requests: 100000 # PUT, COPY, POST, LIST requests
monthly_tier_2_requests: 1000000 # GET, SELECT requests
monthly_egress_data_transfer_gb: 200
aws_dynamodb_table.sessions:
monthly_write_request_units: 5000000
monthly_read_request_units: 25000000
storage_gb: 50
aws_cloudwatch_log_group.app:
monthly_data_ingested_gb: 100
monthly_data_scanned_gb: 50AWS EC2 Instance Example
For EC2 instances, usage parameters let you model reserved instance pricing and non-standard operating hours (for example, dev instances that only run during business hours).
resource_usage:
aws_instance.production:
operating_system: linux
reserved_instance_type: standard
reserved_instance_term: 1_year
reserved_instance_payment_option: all_upfront
monthly_hrs: 730 # full month
aws_instance.dev:
operating_system: linux
monthly_hrs: 176 # ~8 hrs/day, weekdays only| Parameter | Description | Values |
|---|---|---|
operating_system | OS for license cost calculation. | linux, windows, rhel, suse |
reserved_instance_type | RI type. | standard, convertible |
reserved_instance_term | RI commitment period. | 1_year, 3_year |
reserved_instance_payment_option | Payment option. | no_upfront, partial_upfront, all_upfront |
monthly_hrs | Expected running hours per month. | Number (max 730) |
AWS Lambda Example
Lambda pricing depends on the number of invocations, execution duration, and allocated memory.
resource_usage:
aws_lambda_function.api:
monthly_requests: 10000000 # 10M requests
request_duration_ms: 150 # average duration in milliseconds
memory_mb: 512 # allocated memory in MB
aws_lambda_function.cron:
monthly_requests: 43800 # once per minute
request_duration_ms: 2000
memory_mb: 256| Parameter | Description |
|---|---|
monthly_requests | Total invocations per month. |
request_duration_ms | Average execution duration in milliseconds. |
memory_mb | Allocated memory in MB (overrides the Terraform resource attribute if set). |
AWS S3 Bucket Example
S3 pricing is based on storage volume, number of API requests (split by tier), and data transfer out.
resource_usage:
aws_s3_bucket.media:
storage_gb: 2000 # 2 TB stored
monthly_tier_1_requests: 500000 # PUT, COPY, POST, LIST
monthly_tier_2_requests: 5000000 # GET, SELECT, and all other
monthly_egress_data_transfer_gb: 500
monthly_standard_ia_storage_gb: 1000
monthly_glacier_storage_gb: 5000
monthly_glacier_deep_archive_storage_gb: 10000| Parameter | Description |
|---|---|
storage_gb | Total S3 Standard storage in GB. |
monthly_tier_1_requests | PUT, COPY, POST, and LIST requests per month. |
monthly_tier_2_requests | GET, SELECT, and all other requests per month. |
monthly_egress_data_transfer_gb | Data transfer out to the internet in GB per month. |
monthly_standard_ia_storage_gb | Standard-IA storage class in GB. |
monthly_glacier_storage_gb | Glacier Flexible Retrieval storage in GB. |
monthly_glacier_deep_archive_storage_gb | Glacier Deep Archive storage in GB. |
Wildcard and Default Usage
You can use wildcards to set default usage values for all resources of a given type, then override specific resources as needed.
resource_usage:
# Default for all Lambda functions
aws_lambda_function[*]:
monthly_requests: 1000000
request_duration_ms: 200
memory_mb: 256
# Override for a specific function
aws_lambda_function.high_traffic_api:
monthly_requests: 50000000
request_duration_ms: 100
memory_mb: 1024Generating a Usage File
C3X can generate a starter usage file from your Terraform configuration. It scans for resources with variable pricing and creates entries with placeholder values that you can fill in.
c3x estimate --path . --sync-usage-file --usage-file c3x-usage.ymlThis command creates or updates the file, adding any new resources found in your configuration while preserving existing values you have already set.
Using the File
By default, C3X looks for c3x-usage.yml in the current directory. To use a different file or path:
c3x estimate --path . --usage-file path/to/my-usage.ymlFor the full list of supported usage parameters for each resource type, see the example usage files in the C3X repository.
Next Steps
- CLI Reference: See all flags for the
estimatecommand. - CI/CD Integration: Use usage files in your CI pipelines for accurate cost estimates.
- Supported Resources: Check which resources support usage-based pricing.