- Store your metrics parquet files in S3.
- Create an IAM role with read-only S3 access and a web identity trust for Costory.
- In Costory, go to Metrics > Import new metrics datasource > Parquet file (AWS S3).
- Provide the bucket name, prefix, role ARN, and configure metric definitions (value column, date column, aggregation, gap-filling, dimensions, unit).
terraform {
required_providers {
costory = {
source = "costory-io/costory"
version = ">= 0.1.0"
}
}
}
variable "costory_token" {
type = string
description = "Costory API token."
sensitive = true
}
variable "s3_bucket_name" {
type = string
description = "S3 bucket containing parquet metrics files."
}
variable "s3_prefix" {
type = string
description = "S3 key prefix for parquet files."
default = ""
}
variable "role_arn" {
type = string
description = "IAM role ARN for Costory to assume (must match arn:aws:iam::)."
}
provider "costory" {
token = var.costory_token
}
resource "costory_metrics_datasource_s3_parquet" "main" {
name = "AWS S3 Metrics"
bucket_name = var.s3_bucket_name
prefix = var.s3_prefix
role_arn = var.role_arn
metrics_definition {
metric_name = "Usage"
gap_filling = "ZERO"
aggregation = "SUM"
value_column = "usage_amount"
date_column = "usage_start_date"
dimensions = ["service", "region"]
unit = "count"
}
}
resource "costory_metrics_datasource_s3_parquet" "multiple" {
name = "Multiple metrics"
bucket_name = var.s3_bucket_name
prefix = var.s3_prefix
role_arn = var.role_arn
metrics_definition {
metric_name = "Nbr of R&D teams"
gap_filling = "FORWARD_FILL"
aggregation = "SUM"
value_column = "nbr_rd_teams"
date_column = "usage_start_date"
unit = "count"
}
metrics_definition {
metric_name = "Organizations"
gap_filling = "FORWARD_FILL"
aggregation = "SUM"
value_column = "nbr_organizations"
date_column = "usage_start_date"
unit = "count"
}
}
Last modified on March 18, 2026