Skip to main content
The Costory Terraform provider (costory-io/costory) calls the Costory API from your Terraform configuration. You can create billing datasources, publish enrichments, and manage teams and their members, then review every change in a pull request before terraform apply. The source is on GitHub.

Install the provider

Declare the provider in your configuration, then run terraform init.
The enrichment resources need version 0.3.1 or later.

Authenticate

1

Create an API token

In the Costory app, open your organization name (top-right) and go to API Tokens. You can create a user-scoped token, or an organization-scoped token if you are an admin. See API overview.
2

Pass the token to the provider

Declare the token as a sensitive variable and set it in terraform.tfvars or as TF_VAR_costory_api_token.
Writing enrichments requires the API token of an organization admin.

Look up the Costory service account

The costory_service_account data source returns the Costory service account name (service_account) and subscription IDs (sub_ids). The AWS and Google Cloud examples use it to grant Costory read access to your billing exports.

Billing datasources

Each billing datasource is one resource. Costory validates the connection when you apply, so a wrong credential or missing permission fails before any sync starts. terraform destroy deletes the datasource and permanently deletes the data it ingested. See Billing data for history and refresh details. The examples below assume the provider block above. Secrets are passed as sensitive variables.
Field details: Aiven setup.
Field details: Anthropic Console (API usage) setup.
Field details: Anthropic claude.ai setup.
The bucket, IAM role and CUR 2.0 export come from the full configuration in AWS billing setup. The resource below is the Costory part.
The storage account, container, SAS URL and exports come from the full configuration in Azure billing setup. The resource below is the Costory part.
Field details: ClickHouse Cloud setup.
Field details: Cloudflare setup.
Field details: Confluent Cloud setup.
Field details: Cursor setup.
Maps the columns of your own BigQuery cost table to Costory billing fields. billed_cost is required. Full schema: Registry.
Field details: Datadog setup.
Field details: Elastic Cloud setup.
The example grants the Costory service account read access to your billing export dataset, then creates the datasource. Full walkthrough: Google Cloud billing setup.
Field details: Google Cloud CUD export setup.
Field details: OpenAI setup.
Field details: Scaleway setup.
Field details: Snowflake setup.

Enrichments

costory_enrichment stores one YAML lookup file as a draft. costory_enrichments_publish publishes every draft in one transaction after the files are written, and removes the enrichments whose file you deleted. See Publish with Terraform for the file format.

Teams and members

costory_team creates a PUBLIC or PRIVATE team. costory_team_member adds a member by email or user_id, with the OWNER or MEMBER role. Team scopes are still managed in the UI. See Teams.

Billing data

Every provider, history and refresh

Enrichments

YAML lookup files you keep in git

Teams

Team creation, members and scopes

Terraform Registry

Full schema for every resource
Last modified on November 12, 2026