For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inBook a demo
GuidesAPI Reference
Logo
GuidesAPI Reference
  • Getting started
    • Introduction
    • IP Whitelisting
    • Obtaining API keys
    • LLMs.txt
    • MCP server
    • Quickstart
    • Native clients
    • Concepts
    • Embedding authentication
    • Multitenancy
    • Versioning
    • Idempotent requests
    • Events
    • Self-hosted option
    • 2025-09-18 Migration Guide
  • Configuring your connections
    • Overview
    • CDC streaming from databases
    • Syncing to custom webhooks
  • Code examples
    • Overview
    • Bulk sync (ELT) from HubSpot to PostgreSQL
    • Bulk sync (ELT) from Salesforce to S3
    • Bulk sync (ELT) from Salesforce to Snowflake
    • Model sync (Reverse ETL) from Snowflake query to Salesforce
    • Model sync (Reverse ETL) from MongoDB to Salesforce
    • Adding users from Snowflake to Salesloft Cadence
    • Adding contacts from Snowflake to Gong Engage
    • Joined model sync from Postgres, Airtable, and Stripe to Hubspot
    • Model sync from MySQL to Snowflake
    • Model sync from Salesforce to Netsuite
    • Querying Salesforce using SOQL
    • Syncing audiences from Snowflake to LinkedIn Ads
    • Syncing contacts from Google Cloud Storage to Salesforce
    • Syncing contacts from Google Cloud Storage to webhooks
    • Transactional calls with LinkedIn Ads audiences
  • Terraform examples
    • Overview
    • Model sync (Reverse ETL) from BigQuery to Salesforce
    • Model sync (Reverse ETL) from BigQuery to LinkedIn Ads
Log inBook a demo
On this page
  • 1. Configure the Polytomic provider
  • 2. Create a BigQuery Connection
  • 3. Create a LinkedIn Ads Connection
  • 4. Create a source model for the LinkedIn Ads audience
  • 5. Create the Model Sync
  • 6. Apply the configuration
Terraform examples

Model sync (Reverse ETL) from BigQuery to LinkedIn Ads

Was this page helpful?
Previous

This example creates a Model Sync from BigQuery to LinkedIn Ads using the Polytomic Terraform provider.

Prerequisites:

  • Install the Polytomic Terraform provider.
  • Set your Polytomic API key as an environment variable.

1. Configure the Polytomic provider

Configure the Polytomic provider in your Terraform script:

1terraform {
2 required_providers {
3 polytomic = {
4 source = "polytomic/polytomic"
5 version = "~> 1.5"
6 }
7 }
8}
9
10provider "polytomic" {
11 api_key = var.polytomic_api_key
12}

Define var.polytomic_api_key in your variables file or pass it at apply time.

🤝 Partner keys

If you are using a partner key, set partner_key on the provider and set organization on each resource that targets a specific organization.

1provider "polytomic" {
2 partner_key = "<value from settings page>"
3}

2. Create a BigQuery Connection

Define a resource for the BigQuery connection:

1resource "polytomic_bigquery_connection" "user_data" {
2 name = "BigQuery Users"
3
4 configuration = {
5 auth_method = "service_account_key"
6 service_account = file("bq.json")
7 }
8}

This example loads the service account key with the file function. Any string value or variable works as well.

3. Create a LinkedIn Ads Connection

Create the LinkedIn Ads Connection through Polytomic’s OAuth flow so Polytomic can request the required LinkedIn Ads API permissions on your behalf. Use the admin console or embedded authentication.

Once the Connection exists, reference it from Terraform with the Polytomic LinkedIn Ads datasource. Pass the Connection ID from the admin console:

1data "polytomic_linkedinads_connection" "destination" {
2 id = "<linkedin-ads-connection-id>"
3}

4. Create a source model for the LinkedIn Ads audience

Define a model that queries BigQuery:

1resource "polytomic_model" "audience_source" {
2 name = "LinkedIn Audience Source"
3 connection_id = polytomic_bigquery_connection.user_data.id
4
5 configuration = jsonencode({
6 query = "SELECT first_name, last_name, email FROM acme_inc.publicusers"
7 })
8
9 fields = ["email", "first_name", "last_name"]
10}

5. Create the Model Sync

Define a resource that syncs the model to a LinkedIn Ads audience:

1resource "polytomic_sync" "bigquery_to_linkedin_ads_audience" {
2 name = "Audience to LinkedIn Ads Sync"
3 mode = "create"
4 active = true
5
6 schedule = {
7 frequency = "daily"
8 hour = "0"
9 minute = "0"
10 }
11
12 target = {
13 connection_id = data.polytomic_linkedinads_connection.destination.id
14 create = {
15 "name" : var.linkedin_audience_name,
16 "type" : "my_user_audience",
17 "account" : var.linkedin_ad_account
18 }
19 }
20
21 fields = [
22 {
23 source = {
24 model_id = polytomic_model.audience_source.id
25 field = "email"
26 }
27 target = "user_email"
28 },
29 {
30 source = {
31 model_id = polytomic_model.audience_source.id
32 field = "first_name"
33 }
34 target = "firstName"
35 },
36 {
37 source = {
38 model_id = polytomic_model.audience_source.id
39 field = "last_name"
40 }
41 target = "lastName"
42 },
43 ]
44}

6. Apply the configuration

Initialize Terraform and apply:

$terraform init
$terraform apply

Review the planned changes and confirm to proceed.

For more details, see the Polytomic Terraform provider documentation.