The gcp:bigqueryanalyticshub/dataExchange:DataExchange resource, part of the Pulumi GCP provider, defines a BigQuery Analytics Hub data exchange: a container for sharing datasets with controlled discovery and access. This guide focuses on three capabilities: private and public discovery configuration, Data Clean Room setup, and query user email logging.
Data exchanges are containers for dataset listings. The actual dataset sharing happens through listings, which are managed separately. The examples are intentionally small. Combine them with listing resources and IAM policies for complete data sharing workflows.
Create a private data exchange with basic metadata
Most Analytics Hub deployments start by creating a private exchange for controlled dataset distribution within an organization or with specific partners.
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 help users understand the exchange’s purpose. Without setting discoveryType, the exchange defaults to private, meaning only users with explicit access can discover it.
Make a data exchange publicly discoverable
Organizations sharing open datasets can enable public discovery so anyone can find the exchange on the Analytics Hub discovery page.
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 visible on the public discovery page. This setting also applies to all listings under the exchange, making them publicly discoverable as well.
Configure a Data Clean Room exchange
Data Clean Rooms enable privacy-preserving analytics where multiple parties analyze combined datasets without exposing raw data to each other.
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 with dcrExchangeConfig creates a Data Clean Room environment. Data Clean Room exchanges cannot set discoveryType; the API enforces this restriction to maintain privacy guarantees.
Enable query user email logging
For compliance and auditing, exchanges can log the email address of every user who queries linked datasets.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const dataExchange = new gcp.bigqueryanalyticshub.DataExchange("data_exchange", {
location: "US",
dataExchangeId: "tf_test_log_email_data_exchange",
displayName: "tf_test_log_email_data_exchange",
description: "Example for log email test for data exchange",
logLinkedDatasetQueryUserEmail: true,
});
import pulumi
import pulumi_gcp as gcp
data_exchange = gcp.bigqueryanalyticshub.DataExchange("data_exchange",
location="US",
data_exchange_id="tf_test_log_email_data_exchange",
display_name="tf_test_log_email_data_exchange",
description="Example for log email test for data exchange",
log_linked_dataset_query_user_email=True)
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("tf_test_log_email_data_exchange"),
DisplayName: pulumi.String("tf_test_log_email_data_exchange"),
Description: pulumi.String("Example for log email test for data exchange"),
LogLinkedDatasetQueryUserEmail: pulumi.Bool(true),
})
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 = "tf_test_log_email_data_exchange",
DisplayName = "tf_test_log_email_data_exchange",
Description = "Example for log email test for data exchange",
LogLinkedDatasetQueryUserEmail = true,
});
});
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("tf_test_log_email_data_exchange")
.displayName("tf_test_log_email_data_exchange")
.description("Example for log email test for data exchange")
.logLinkedDatasetQueryUserEmail(true)
.build());
}
}
resources:
dataExchange:
type: gcp:bigqueryanalyticshub:DataExchange
name: data_exchange
properties:
location: US
dataExchangeId: tf_test_log_email_data_exchange
displayName: tf_test_log_email_data_exchange
description: Example for log email test for data exchange
logLinkedDatasetQueryUserEmail: true
Setting logLinkedDatasetQueryUserEmail to true enables email logging for all queries on linked datasets. This setting is irreversible; once enabled, it cannot be disabled. Use this for compliance requirements that mandate tracking data access.
Beyond these examples
These snippets focus on specific data exchange features: private and public discovery modes, Data Clean Room configuration, and query user email logging. 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 the listings and permissions that enable actual data sharing.
To keep things focused, common exchange patterns are omitted, including:
- Listing creation and management (separate resource)
- IAM policies and subscriber permissions
- Documentation and icon customization (documentation, icon properties)
- Primary contact configuration (primaryContact property)
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 FREEFrequently Asked Questions
Immutability & Limitations
dataExchangeId, location, project, and sharingEnvironmentConfig. Changing any of these requires recreating the resource.logLinkedDatasetQueryUserEmail to true, it cannot be turned off. Consider this carefully before enabling.discoveryType overwrites the discovery type for all listings under the exchange. This change cascades to all child listings.Data Clean Rooms
sharingEnvironmentConfig with dcrExchangeConfig. Do not set discoveryType, as it cannot be configured for Data Clean Rooms.discoveryType configured. This field is only valid for standard data exchanges.Discovery & Visibility
discoveryType to DISCOVERY_TYPE_PRIVATE for private exchanges or DISCOVERY_TYPE_PUBLIC for publicly discoverable exchanges. This controls visibility on the discovery page.Naming & Constraints
dataExchangeId must contain only Unicode letters, numbers (0-9), and underscores (_). Avoid URL-escaping characters, non-ASCII characters, and spaces.displayName must contain only Unicode letters, numbers (0-9), underscores (_), dashes (-), and spaces ( ). It cannot start or end with spaces.Using a different cloud?
Explore analytics guides for other cloud providers: