Skip to main content

Census Terraform Provider

The Census Terraform Provider enables you to manage Census resources programmatically using infrastructure as code (IaC). Built to support modern DevOps workflows, the provider allows you to version control, automate, and reproducibly deploy your Census configurations.

Why Use Terraform with Census?

  • Version Control - Track all changes to your Census configuration in Git alongside your infrastructure code
  • Reproducibility - Deploy identical configurations across development, staging, and production environments
  • Automation - Integrate Census setup into your CI/CD pipelines for automated deployments
  • Multi-Region - Manage Census resources across US, EU, and AU regions from a single provider

Getting Started

Installation

The Census Terraform Provider is available in the Terraform Registry. Add it to your Terraform configuration:
terraform {
  required_providers {
    census = {
      source  = "sutrolabs/census"
      version = "~> 0.2.0"
    }
  }
}

provider "census" {
  personal_access_token = var.census_personal_token
  region                = "us"  # Options: "us", "eu", "au"
}

Authentication

The provider requires a Census personal access token. Generate one from your Census account settings.
Store your personal access token securely using environment variables or a secrets management system. Never commit tokens to version control.
Using Environment Variables:
export CENSUS_PERSONAL_ACCESS_TOKEN="your-token-here"
The provider will automatically detect the CENSUS_PERSONAL_ACCESS_TOKEN environment variable. Using Terraform Variables:
variable "census_personal_token" {
  type      = string
  sensitive = true
}

provider "census" {
  personal_access_token = var.census_personal_token
  region                = "us"
}

Basic Example

Here’s a complete example showing how to manage Census resources with Terraform:
# Configure the Census Provider
provider "census" {
  personal_access_token = var.census_personal_token
  region                = "us"
}

# Create a workspace
resource "census_workspace" "data_team" {
  name = "Data Team Workspace"
  notification_emails = [
    "data-alerts@company.com"
  ]
  return_workspace_api_key = true
}

# Configure a data warehouse source
resource "census_source" "warehouse" {
  workspace_id = census_workspace.data_team.id
  name         = "Production Warehouse"
  type         = "snowflake"

  connection_config = {
    account   = "xy12345.us-east-1"
    database  = "ANALYTICS"
    warehouse = "COMPUTE_WH"
    role      = "CENSUS_ROLE"
    username  = "census_user"
    password  = var.snowflake_password
  }
}

# Configure a destination
resource "census_destination" "crm" {
  workspace_id = census_workspace.data_team.id
  name         = "Production CRM"
  type         = "salesforce"

  connection_config = {
    instance_url = var.salesforce_instance_url
    access_token = var.salesforce_token
  }
}

# Create a data sync
resource "census_sync" "users_to_crm" {
  workspace_id = census_workspace.data_team.id
  label        = "Users to CRM"

  source_attributes {
    connection_id = census_source.warehouse.id
    object {
      type         = "table"
      table_name   = "users"
      table_schema = "public"
    }
  }

  destination_attributes {
    connection_id = census_destination.crm.id
    object        = "Contact"
  }

  operation = "upsert"

  field_mapping {
    from                  = "email"
    to                    = "Email"
    is_primary_identifier = true
  }

  field_mapping {
    from = "first_name"
    to   = "FirstName"
  }

  field_mapping {
    from = "last_name"
    to   = "LastName"
  }

  run_mode {
    type = "triggered"
    triggers {
      schedule {
        frequency = "daily"
        hour      = 8
        minute    = 0
      }
    }
  }

  paused = true
}

Available Resources

The provider supports the complete Census data pipeline:
  • census_workspace - Create and manage Census workspaces
  • census_source - Connect data warehouses (Snowflake, BigQuery, Postgres, etc.)
  • census_dataset - Define SQL transformations
  • census_destination - Configure business tool integrations (Salesforce, HubSpot, etc.)
  • census_sync - Define data syncs with field mappings and schedules
All resources have corresponding data sources for read-only operations.

Resources

Support

Need help with the Terraform Provider? We’re here to help: