The gcp:bigquery/datasetIamBinding:DatasetIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for BigQuery datasets. It controls which identities can access dataset resources through authoritative role assignment. This guide focuses on three capabilities: authoritative role binding for multiple members, time-based access with IAM conditions, and non-authoritative member addition.
DatasetIamBinding references existing BigQuery datasets and cannot be used alongside DatasetAccess resources or the access field on Dataset resources. The examples are intentionally small. Combine them with your own dataset infrastructure and identity management.
Grant a role to multiple members with DatasetIamBinding
When managing dataset access, teams often need to grant the same role to multiple users or service accounts at once.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const dataset = new gcp.bigquery.Dataset("dataset", {datasetId: "example_dataset"});
const reader = new gcp.bigquery.DatasetIamBinding("reader", {
datasetId: dataset.datasetId,
role: "roles/bigquery.dataViewer",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
dataset = gcp.bigquery.Dataset("dataset", dataset_id="example_dataset")
reader = gcp.bigquery.DatasetIamBinding("reader",
dataset_id=dataset.dataset_id,
role="roles/bigquery.dataViewer",
members=["user:jane@example.com"])
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/bigquery"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
dataset, err := bigquery.NewDataset(ctx, "dataset", &bigquery.DatasetArgs{
DatasetId: pulumi.String("example_dataset"),
})
if err != nil {
return err
}
_, err = bigquery.NewDatasetIamBinding(ctx, "reader", &bigquery.DatasetIamBindingArgs{
DatasetId: dataset.DatasetId,
Role: pulumi.String("roles/bigquery.dataViewer"),
Members: pulumi.StringArray{
pulumi.String("user:jane@example.com"),
},
})
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 dataset = new Gcp.BigQuery.Dataset("dataset", new()
{
DatasetId = "example_dataset",
});
var reader = new Gcp.BigQuery.DatasetIamBinding("reader", new()
{
DatasetId = dataset.DatasetId,
Role = "roles/bigquery.dataViewer",
Members = new[]
{
"user:jane@example.com",
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigquery.Dataset;
import com.pulumi.gcp.bigquery.DatasetArgs;
import com.pulumi.gcp.bigquery.DatasetIamBinding;
import com.pulumi.gcp.bigquery.DatasetIamBindingArgs;
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 dataset = new Dataset("dataset", DatasetArgs.builder()
.datasetId("example_dataset")
.build());
var reader = new DatasetIamBinding("reader", DatasetIamBindingArgs.builder()
.datasetId(dataset.datasetId())
.role("roles/bigquery.dataViewer")
.members("user:jane@example.com")
.build());
}
}
resources:
reader:
type: gcp:bigquery:DatasetIamBinding
properties:
datasetId: ${dataset.datasetId}
role: roles/bigquery.dataViewer
members:
- user:jane@example.com
dataset:
type: gcp:bigquery:Dataset
properties:
datasetId: example_dataset
The DatasetIamBinding resource manages all members for a single role authoritatively. The members array lists identities that receive the specified role. Each binding replaces any existing members for that role, so include everyone who needs access. The role property uses the full IAM role format like roles/bigquery.dataViewer.
Add time-based access with IAM conditions
Temporary access grants are common for contractors or time-limited projects, and IAM conditions automate permission expiration.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const dataset = new gcp.bigquery.Dataset("dataset", {datasetId: "example_dataset"});
const reader = new gcp.bigquery.DatasetIamBinding("reader", {
datasetId: dataset.datasetId,
role: "roles/bigquery.dataViewer",
members: ["user:jane@example.com"],
condition: {
title: "expires_after_2029_12_31",
description: "Expiring at midnight of 2029-12-31",
expression: "request.time < timestamp(\"2030-01-01T00:00:00Z\")",
},
});
import pulumi
import pulumi_gcp as gcp
dataset = gcp.bigquery.Dataset("dataset", dataset_id="example_dataset")
reader = gcp.bigquery.DatasetIamBinding("reader",
dataset_id=dataset.dataset_id,
role="roles/bigquery.dataViewer",
members=["user:jane@example.com"],
condition={
"title": "expires_after_2029_12_31",
"description": "Expiring at midnight of 2029-12-31",
"expression": "request.time < timestamp(\"2030-01-01T00:00:00Z\")",
})
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/bigquery"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
dataset, err := bigquery.NewDataset(ctx, "dataset", &bigquery.DatasetArgs{
DatasetId: pulumi.String("example_dataset"),
})
if err != nil {
return err
}
_, err = bigquery.NewDatasetIamBinding(ctx, "reader", &bigquery.DatasetIamBindingArgs{
DatasetId: dataset.DatasetId,
Role: pulumi.String("roles/bigquery.dataViewer"),
Members: pulumi.StringArray{
pulumi.String("user:jane@example.com"),
},
Condition: &bigquery.DatasetIamBindingConditionArgs{
Title: pulumi.String("expires_after_2029_12_31"),
Description: pulumi.String("Expiring at midnight of 2029-12-31"),
Expression: pulumi.String("request.time < timestamp(\"2030-01-01T00:00:00Z\")"),
},
})
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 dataset = new Gcp.BigQuery.Dataset("dataset", new()
{
DatasetId = "example_dataset",
});
var reader = new Gcp.BigQuery.DatasetIamBinding("reader", new()
{
DatasetId = dataset.DatasetId,
Role = "roles/bigquery.dataViewer",
Members = new[]
{
"user:jane@example.com",
},
Condition = new Gcp.BigQuery.Inputs.DatasetIamBindingConditionArgs
{
Title = "expires_after_2029_12_31",
Description = "Expiring at midnight of 2029-12-31",
Expression = "request.time < timestamp(\"2030-01-01T00:00:00Z\")",
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigquery.Dataset;
import com.pulumi.gcp.bigquery.DatasetArgs;
import com.pulumi.gcp.bigquery.DatasetIamBinding;
import com.pulumi.gcp.bigquery.DatasetIamBindingArgs;
import com.pulumi.gcp.bigquery.inputs.DatasetIamBindingConditionArgs;
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 dataset = new Dataset("dataset", DatasetArgs.builder()
.datasetId("example_dataset")
.build());
var reader = new DatasetIamBinding("reader", DatasetIamBindingArgs.builder()
.datasetId(dataset.datasetId())
.role("roles/bigquery.dataViewer")
.members("user:jane@example.com")
.condition(DatasetIamBindingConditionArgs.builder()
.title("expires_after_2029_12_31")
.description("Expiring at midnight of 2029-12-31")
.expression("request.time < timestamp(\"2030-01-01T00:00:00Z\")")
.build())
.build());
}
}
resources:
reader:
type: gcp:bigquery:DatasetIamBinding
properties:
datasetId: ${dataset.datasetId}
role: roles/bigquery.dataViewer
members:
- user:jane@example.com
condition:
title: expires_after_2029_12_31
description: Expiring at midnight of 2029-12-31
expression: request.time < timestamp("2030-01-01T00:00:00Z")
dataset:
type: gcp:bigquery:Dataset
properties:
datasetId: example_dataset
The condition block adds temporal constraints to role bindings. The expression property uses CEL (Common Expression Language) to define when access is valid. Here, access expires at midnight on 2030-01-01. The title and description provide human-readable context for the condition. Conditions work with both DatasetIamBinding and DatasetIamMember.
Add individual members with DatasetIamMember
When you need to add one person to a role without affecting other members, DatasetIamMember provides non-authoritative access control.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const dataset = new gcp.bigquery.Dataset("dataset", {datasetId: "example_dataset"});
const editor = new gcp.bigquery.DatasetIamMember("editor", {
datasetId: dataset.datasetId,
role: "roles/bigquery.dataEditor",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
dataset = gcp.bigquery.Dataset("dataset", dataset_id="example_dataset")
editor = gcp.bigquery.DatasetIamMember("editor",
dataset_id=dataset.dataset_id,
role="roles/bigquery.dataEditor",
member="user:jane@example.com")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/bigquery"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
dataset, err := bigquery.NewDataset(ctx, "dataset", &bigquery.DatasetArgs{
DatasetId: pulumi.String("example_dataset"),
})
if err != nil {
return err
}
_, err = bigquery.NewDatasetIamMember(ctx, "editor", &bigquery.DatasetIamMemberArgs{
DatasetId: dataset.DatasetId,
Role: pulumi.String("roles/bigquery.dataEditor"),
Member: pulumi.String("user:jane@example.com"),
})
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 dataset = new Gcp.BigQuery.Dataset("dataset", new()
{
DatasetId = "example_dataset",
});
var editor = new Gcp.BigQuery.DatasetIamMember("editor", new()
{
DatasetId = dataset.DatasetId,
Role = "roles/bigquery.dataEditor",
Member = "user:jane@example.com",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.bigquery.Dataset;
import com.pulumi.gcp.bigquery.DatasetArgs;
import com.pulumi.gcp.bigquery.DatasetIamMember;
import com.pulumi.gcp.bigquery.DatasetIamMemberArgs;
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 dataset = new Dataset("dataset", DatasetArgs.builder()
.datasetId("example_dataset")
.build());
var editor = new DatasetIamMember("editor", DatasetIamMemberArgs.builder()
.datasetId(dataset.datasetId())
.role("roles/bigquery.dataEditor")
.member("user:jane@example.com")
.build());
}
}
resources:
editor:
type: gcp:bigquery:DatasetIamMember
properties:
datasetId: ${dataset.datasetId}
role: roles/bigquery.dataEditor
member: user:jane@example.com
dataset:
type: gcp:bigquery:Dataset
properties:
datasetId: example_dataset
Unlike DatasetIamBinding, DatasetIamMember adds a single identity without replacing existing members. The member property (singular) specifies one identity, while the role property defines what they can do. Use this when multiple teams manage access to the same dataset, or when you want to add access without knowing who else has it.
Beyond these examples
These snippets focus on specific IAM binding features: authoritative role binding, non-authoritative member addition, and time-based access with IAM conditions. They’re intentionally minimal rather than full access control policies.
The examples reference pre-existing infrastructure such as BigQuery datasets and GCP project context. They focus on configuring IAM bindings rather than provisioning datasets or managing full policies.
To keep things focused, common IAM patterns are omitted, including:
- Full policy replacement (DatasetIamPolicy)
- Project-level configuration (project property)
- Advanced condition expressions (resource attributes, request context)
- Authorized views (requires DatasetAccess resource)
These omissions are intentional: the goal is to illustrate how each IAM binding feature is wired, not provide drop-in access control modules. See the DatasetIamBinding resource reference for all available configuration options.
Let's manage GCP BigQuery Dataset IAM Bindings
Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.
Try Pulumi Cloud for FREEFrequently Asked Questions
Resource Conflicts & Compatibility
DatasetIamBinding, DatasetIamPolicy, DatasetIamMember) OR DatasetAccess/access field, not both.gcp.bigquery.DatasetAccess instead.DatasetIamPolicy cannot be used with DatasetIamBinding or DatasetIamMember as they will fight over the policy. Use either DatasetIamPolicy (authoritative) or the granular resources, not both.Role Configuration
roles/bigquery.dataOwner, roles/bigquery.dataEditor, and roles/bigquery.dataViewer.[projects|organizations]/{parent-name}/roles/{role-name}. For example: projects/my-project/roles/my-custom-role.user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, allUsers, allAuthenticatedUsers, projectOwners, projectReaders, projectWriters, and iamMember:{principal} for federated identities.Resource Selection
DatasetIamPolicy to replace the entire policy authoritatively, DatasetIamBinding to manage a specific role authoritatively while preserving other roles, or DatasetIamMember to add individual members non-authoritatively while preserving other members.Advanced Features
condition property with title, description, and expression fields. For example, set expression to request.time < timestamp("2030-01-01T00:00:00Z") for time-based expiration.datasetId, project, role, and condition properties are immutable and cannot be changed after the resource is created.