Skip to content

mixpanel_warehouse_source (Resource)

Manages a Mixpanel Warehouse Source (mixpanel_warehouse_source) — an inbound data connection that imports data from an external data warehouse (BigQuery, Snowflake, Redshift, Databricks, or Postgres) into Mixpanel. Connection configuration is passed as JSON via the params attribute; its shape depends on the warehouse_type.

Example Usage

# BigQuery warehouse source with service account credentials
resource "mixpanel_warehouse_source" "bq" {
  project_id     = 1234567
  source_name    = "prod-bigquery"
  warehouse_type = "bigquery"

  params = jsonencode({
    project_id = "my-gcp-project-id"
    dataset    = "mixpanel_export"
    service_account_key = jsonencode({
      type                        = "service_account"
      project_id                  = "my-gcp-project-id"
      private_key_id              = "abc123def456"
      private_key                 = "-----BEGIN PRIVATE KEY-----\nMIIE...DUMMY...KEY\n-----END PRIVATE KEY-----\n"
      client_email                = "mixpanel-sa@my-gcp-project-id.iam.gserviceaccount.com"
      client_id                   = "1234567890"
      auth_uri                    = "https://accounts.google.com/o/oauth2/auth"
      token_uri                   = "https://oauth2.googleapis.com/token"
      auth_provider_x509_cert_url = "https://www.googleapis.com/oauth2/v1/certs"
      client_x509_cert_url        = "https://www.googleapis.com/robot/v1/metadata/x509/mixpanel-sa%40my-gcp-project-id.iam.gserviceaccount.com"
    })
  })
}

# Alternative: load service account key from a file
resource "mixpanel_warehouse_source" "bq_from_file" {
  project_id     = 1234567
  source_name    = "prod-bigquery-file"
  warehouse_type = "bigquery"

  params = jsonencode({
    project_id          = "my-gcp-project-id"
    dataset             = "mixpanel_export"
    service_account_key = file("${path.module}/sa-key.json")
  })
}

# Alternative: reference from variable
resource "mixpanel_warehouse_source" "bq_from_var" {
  project_id     = 1234567
  source_name    = "prod-bigquery-var"
  warehouse_type = "bigquery"

  params = jsonencode({
    project_id          = var.gcp_project_id
    dataset             = var.bq_dataset
    service_account_key = var.gcp_service_account_key
  })
}

Schema

Required

  • warehouse_type (String)

Optional

  • params (String) Connection config as JSON; its shape depends on warehouse_type. Effectively required when creating a source, but modeled as Optional so terraform import can round-trip (the GET never echoes the connection config / credentials back, so it is preserved from prior state and is not refreshed on read).
  • project_id (Number)
  • source_id (Number)
  • source_name (String)

Read-Only

  • created (String)
  • creator_email (String)
  • creator_id (Number)
  • creator_name (String)
  • id (Number) The ID of this resource.

Import

Import a warehouse source using PROJECT_ID:SOURCE_ID:

import {
  to = mixpanel_warehouse_source.bq
  id = "1234567:8821"
}
terraform import mixpanel_warehouse_source.bq 1234567:8821

Note: The params attribute contains connection credentials that are write-only and never returned by the API. After import, params will be null in state and must be re-supplied in your Terraform configuration. The warehouse source will remain functional; only the Terraform state will be incomplete until you provide the configuration values.