Create GCP BigQuery Analytics Hub Data Exchanges

The gcp:bigqueryanalyticshub/dataExchange:DataExchange resource, part of the Pulumi GCP provider, defines an Analytics Hub data exchange: a container for data listings with discovery and sharing controls. This guide focuses on two capabilities: private and public discovery modes, and Data Clean Room configuration.

Data exchanges require a GCP project with BigQuery and Analytics Hub APIs enabled. Listings are created separately and attached to exchanges. The examples are intentionally small. Combine them with your own listing resources and access policies.

Create a private data exchange with basic metadata

Most deployments start with a private exchange that restricts discovery to users with explicit access, suitable for internal data sharing.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const dataExchange = new gcp.bigqueryanalyticshub.DataExchange("data_exchange", {
    location: "US",
    dataExchangeId: "my_data_exchange",
    displayName: "my_data_exchange",
    description: "example data exchange",
});
import pulumi
import pulumi_gcp as gcp

data_exchange = gcp.bigqueryanalyticshub.DataExchange("data_exchange",
    location="US",
    data_exchange_id="my_data_exchange",
    display_name="my_data_exchange",
    description="example data exchange")
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/bigqueryanalyticshub"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := bigqueryanalyticshub.NewDataExchange(ctx, "data_exchange", &bigqueryanalyticshub.DataExchangeArgs{
			Location:       pulumi.String("US"),
			DataExchangeId: pulumi.String("my_data_exchange"),
			DisplayName:    pulumi.String("my_data_exchange"),
			Description:    pulumi.String("example data exchange"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var dataExchange = new Gcp.BigQueryAnalyticsHub.DataExchange("data_exchange", new()
    {
        Location = "US",
        DataExchangeId = "my_data_exchange",
        DisplayName = "my_data_exchange",
        Description = "example data exchange",
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigqueryanalyticshub.DataExchange;
import com.pulumi.gcp.bigqueryanalyticshub.DataExchangeArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var dataExchange = new DataExchange("dataExchange", DataExchangeArgs.builder()
            .location("US")
            .dataExchangeId("my_data_exchange")
            .displayName("my_data_exchange")
            .description("example data exchange")
            .build());

    }
}
resources:
  dataExchange:
    type: gcp:bigqueryanalyticshub:DataExchange
    name: data_exchange
    properties:
      location: US
      dataExchangeId: my_data_exchange
      displayName: my_data_exchange
      description: example data exchange

The dataExchangeId provides a unique identifier within the location. The displayName and description appear in the Analytics Hub UI. When discoveryType is omitted, the exchange defaults to DISCOVERY_TYPE_PRIVATE, hiding it from public discovery pages.

Configure a Data Clean Room exchange

Data Clean Rooms enable privacy-preserving collaboration by restricting how subscribers query shared datasets.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const dataExchange = new gcp.bigqueryanalyticshub.DataExchange("data_exchange", {
    location: "US",
    dataExchangeId: "dcr_data_exchange",
    displayName: "dcr_data_exchange",
    description: "example dcr data exchange",
    sharingEnvironmentConfig: {
        dcrExchangeConfig: {},
    },
});
import pulumi
import pulumi_gcp as gcp

data_exchange = gcp.bigqueryanalyticshub.DataExchange("data_exchange",
    location="US",
    data_exchange_id="dcr_data_exchange",
    display_name="dcr_data_exchange",
    description="example dcr data exchange",
    sharing_environment_config={
        "dcr_exchange_config": {},
    })
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/bigqueryanalyticshub"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := bigqueryanalyticshub.NewDataExchange(ctx, "data_exchange", &bigqueryanalyticshub.DataExchangeArgs{
			Location:       pulumi.String("US"),
			DataExchangeId: pulumi.String("dcr_data_exchange"),
			DisplayName:    pulumi.String("dcr_data_exchange"),
			Description:    pulumi.String("example dcr data exchange"),
			SharingEnvironmentConfig: &bigqueryanalyticshub.DataExchangeSharingEnvironmentConfigArgs{
				DcrExchangeConfig: &bigqueryanalyticshub.DataExchangeSharingEnvironmentConfigDcrExchangeConfigArgs{},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var dataExchange = new Gcp.BigQueryAnalyticsHub.DataExchange("data_exchange", new()
    {
        Location = "US",
        DataExchangeId = "dcr_data_exchange",
        DisplayName = "dcr_data_exchange",
        Description = "example dcr data exchange",
        SharingEnvironmentConfig = new Gcp.BigQueryAnalyticsHub.Inputs.DataExchangeSharingEnvironmentConfigArgs
        {
            DcrExchangeConfig = null,
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigqueryanalyticshub.DataExchange;
import com.pulumi.gcp.bigqueryanalyticshub.DataExchangeArgs;
import com.pulumi.gcp.bigqueryanalyticshub.inputs.DataExchangeSharingEnvironmentConfigArgs;
import com.pulumi.gcp.bigqueryanalyticshub.inputs.DataExchangeSharingEnvironmentConfigDcrExchangeConfigArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var dataExchange = new DataExchange("dataExchange", DataExchangeArgs.builder()
            .location("US")
            .dataExchangeId("dcr_data_exchange")
            .displayName("dcr_data_exchange")
            .description("example dcr data exchange")
            .sharingEnvironmentConfig(DataExchangeSharingEnvironmentConfigArgs.builder()
                .dcrExchangeConfig(DataExchangeSharingEnvironmentConfigDcrExchangeConfigArgs.builder()
                    .build())
                .build())
            .build());

    }
}
resources:
  dataExchange:
    type: gcp:bigqueryanalyticshub:DataExchange
    name: data_exchange
    properties:
      location: US
      dataExchangeId: dcr_data_exchange
      displayName: dcr_data_exchange
      description: example dcr data exchange
      sharingEnvironmentConfig:
        dcrExchangeConfig: {}

The sharingEnvironmentConfig property with dcrExchangeConfig designates this as a Data Clean Room exchange. DCR exchanges cannot set discoveryType; they enforce query restrictions that prevent subscribers from extracting raw data or identifying individuals.

Publish a data exchange for public discovery

Public exchanges appear on the Analytics Hub discovery page, allowing any user to find and subscribe to listings.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const dataExchange = new gcp.bigqueryanalyticshub.DataExchange("data_exchange", {
    location: "US",
    dataExchangeId: "public_data_exchange",
    displayName: "public_data_exchange",
    description: "Example for public data exchange",
    discoveryType: "DISCOVERY_TYPE_PUBLIC",
});
import pulumi
import pulumi_gcp as gcp

data_exchange = gcp.bigqueryanalyticshub.DataExchange("data_exchange",
    location="US",
    data_exchange_id="public_data_exchange",
    display_name="public_data_exchange",
    description="Example for public data exchange",
    discovery_type="DISCOVERY_TYPE_PUBLIC")
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/bigqueryanalyticshub"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := bigqueryanalyticshub.NewDataExchange(ctx, "data_exchange", &bigqueryanalyticshub.DataExchangeArgs{
			Location:       pulumi.String("US"),
			DataExchangeId: pulumi.String("public_data_exchange"),
			DisplayName:    pulumi.String("public_data_exchange"),
			Description:    pulumi.String("Example for public data exchange"),
			DiscoveryType:  pulumi.String("DISCOVERY_TYPE_PUBLIC"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var dataExchange = new Gcp.BigQueryAnalyticsHub.DataExchange("data_exchange", new()
    {
        Location = "US",
        DataExchangeId = "public_data_exchange",
        DisplayName = "public_data_exchange",
        Description = "Example for public data exchange",
        DiscoveryType = "DISCOVERY_TYPE_PUBLIC",
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigqueryanalyticshub.DataExchange;
import com.pulumi.gcp.bigqueryanalyticshub.DataExchangeArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var dataExchange = new DataExchange("dataExchange", DataExchangeArgs.builder()
            .location("US")
            .dataExchangeId("public_data_exchange")
            .displayName("public_data_exchange")
            .description("Example for public data exchange")
            .discoveryType("DISCOVERY_TYPE_PUBLIC")
            .build());

    }
}
resources:
  dataExchange:
    type: gcp:bigqueryanalyticshub:DataExchange
    name: data_exchange
    properties:
      location: US
      dataExchangeId: public_data_exchange
      displayName: public_data_exchange
      description: Example for public data exchange
      discoveryType: DISCOVERY_TYPE_PUBLIC

Setting discoveryType to DISCOVERY_TYPE_PUBLIC makes the exchange and its listings visible on the public discovery page. This visibility model suits open data initiatives or commercial data products where broad discoverability is desired.

Beyond these examples

These snippets focus on specific data exchange features: private and public discovery modes, and Data Clean Room configuration. They’re intentionally minimal rather than full data sharing solutions.

The examples assume pre-existing infrastructure such as a GCP project with BigQuery and Analytics Hub APIs enabled. They focus on configuring the exchange container rather than provisioning listings or access policies.

To keep things focused, common exchange patterns are omitted, including:

  • Query user email logging (logLinkedDatasetQueryUserEmail)
  • Primary contact and documentation metadata
  • Custom icons for exchange branding
  • Listing creation and management within exchanges

These omissions are intentional: the goal is to illustrate how each exchange feature is wired, not provide drop-in data sharing modules. See the BigQuery Analytics Hub DataExchange resource reference for all available configuration options.

Let's create GCP BigQuery Analytics Hub Data Exchanges

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Immutability & Lifecycle
Can I disable email logging after enabling it?
No, once you set logLinkedDatasetQueryUserEmail to true, it cannot be turned off. Consider carefully before enabling this feature.
What properties can't be changed after creating a data exchange?
Four properties are immutable: dataExchangeId, location, project, and sharingEnvironmentConfig. You’ll need to recreate the exchange to change any of these.
What happens when I update the discovery type?
Updating discoveryType overwrites the discovery type for all listings under this exchange, not just the exchange itself.
Data Clean Rooms
How do I create a Data Clean Room exchange?
Set sharingEnvironmentConfig with dcrExchangeConfig as shown in the DCR example. This field is required for data clean room exchanges.
Can I set a discovery type for Data Clean Room exchanges?
No, discoveryType cannot be set for Data Clean Room exchanges. Omit this field when using sharingEnvironmentConfig.
Configuration & Setup
What are the discovery type options for my data exchange?
You can choose DISCOVERY_TYPE_PRIVATE (default) or DISCOVERY_TYPE_PUBLIC to control visibility on the discovery page.
What characters are allowed in the data exchange ID?
Use only Unicode letters, numbers (0-9), and underscores (_). Avoid characters requiring URL-escaping, non-ASCII characters, and spaces.
What does enabling email logging do?
When logLinkedDatasetQueryUserEmail is true, all queries on linked datasets log the email address of the querying user.

Using a different cloud?

Explore analytics guides for other cloud providers: