Skip to content

sutrolabs/terraform-provider-census

Repository files navigation

Terraform Provider for Census

A Terraform provider for managing Census resources. Census enables you to sync data from your warehouse to all your operational tools, and this provider allows you to manage Census infrastructure as code.

Features

  • Multi-region support: Works with US, EU, and AU Census regions
  • Complete Census workflow: Manage workspaces, sources, datasets, destinations, and syncs
  • PAT-only authentication: Uses personal access tokens with dynamic workspace token retrieval
  • Import support: Import existing Census resources into Terraform state
  • Staging environment support: Configure custom base URLs for testing

Installation

terraform {
  required_providers {
    census = {
      source  = "sutrolabs/census"
      version = "~> 0.2.0"
    }
  }
}

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

Usage

resource "census_workspace" "data_team" {
  name = "Data Team Workspace"
  notification_emails = ["[email protected]"]
}

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
  }
}

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"
  }

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

Resources

  • census_workspace - Manage Census workspaces
  • census_source - Data warehouse connections (Snowflake, BigQuery, Postgres, etc.)
  • census_destination - Business tool integrations (Salesforce, HubSpot, etc.)
  • census_dataset - SQL datasets for data transformation
  • census_sync - Data syncs between sources and destinations

Data Sources

All resources have corresponding data sources for read-only operations. See documentation for details.

Documentation

Contributing

At this time we are not accepting external contributions to the provider. Please contact Census Support with feature requests or bug reports.

Support

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

About

Terraform Provider for Census

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •