The gcp:bigquery/iamPolicy:IamPolicy resource, part of the Pulumi GCP provider, manages IAM access control for BigQuery tables through three distinct approaches. This guide focuses on three capabilities: authoritative policy replacement (IamPolicy), role-level member binding (IamBinding), and individual member grants (IamMember).
These resources reference existing BigQuery tables and datasets. IamPolicy replaces the entire access policy and cannot be combined with IamBinding or IamMember on the same table. IamBinding and IamMember can coexist as long as they don’t manage the same role. The examples are intentionally small. Combine them with your own table and dataset infrastructure.
Replace the entire IAM policy for a table
When you need complete control over table access, you can set the entire IAM policy at once, replacing any existing permissions.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const admin = gcp.organizations.getIAMPolicy({
bindings: [{
role: "roles/bigquery.dataOwner",
members: ["user:jane@example.com"],
}],
});
const policy = new gcp.bigquery.IamPolicy("policy", {
project: test.project,
datasetId: test.datasetId,
tableId: test.tableId,
policyData: admin.then(admin => admin.policyData),
});
import pulumi
import pulumi_gcp as gcp
admin = gcp.organizations.get_iam_policy(bindings=[{
"role": "roles/bigquery.dataOwner",
"members": ["user:jane@example.com"],
}])
policy = gcp.bigquery.IamPolicy("policy",
project=test["project"],
dataset_id=test["datasetId"],
table_id=test["tableId"],
policy_data=admin.policy_data)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/bigquery"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/organizations"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
admin, err := organizations.LookupIAMPolicy(ctx, &organizations.LookupIAMPolicyArgs{
Bindings: []organizations.GetIAMPolicyBinding{
{
Role: "roles/bigquery.dataOwner",
Members: []string{
"user:jane@example.com",
},
},
},
}, nil)
if err != nil {
return err
}
_, err = bigquery.NewIamPolicy(ctx, "policy", &bigquery.IamPolicyArgs{
Project: pulumi.Any(test.Project),
DatasetId: pulumi.Any(test.DatasetId),
TableId: pulumi.Any(test.TableId),
PolicyData: pulumi.String(admin.PolicyData),
})
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 admin = Gcp.Organizations.GetIAMPolicy.Invoke(new()
{
Bindings = new[]
{
new Gcp.Organizations.Inputs.GetIAMPolicyBindingInputArgs
{
Role = "roles/bigquery.dataOwner",
Members = new[]
{
"user:jane@example.com",
},
},
},
});
var policy = new Gcp.BigQuery.IamPolicy("policy", new()
{
Project = test.Project,
DatasetId = test.DatasetId,
TableId = test.TableId,
PolicyData = admin.Apply(getIAMPolicyResult => getIAMPolicyResult.PolicyData),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetIAMPolicyArgs;
import com.pulumi.gcp.bigquery.IamPolicy;
import com.pulumi.gcp.bigquery.IamPolicyArgs;
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) {
final var admin = OrganizationsFunctions.getIAMPolicy(GetIAMPolicyArgs.builder()
.bindings(GetIAMPolicyBindingArgs.builder()
.role("roles/bigquery.dataOwner")
.members("user:jane@example.com")
.build())
.build());
var policy = new IamPolicy("policy", IamPolicyArgs.builder()
.project(test.project())
.datasetId(test.datasetId())
.tableId(test.tableId())
.policyData(admin.policyData())
.build());
}
}
resources:
policy:
type: gcp:bigquery:IamPolicy
properties:
project: ${test.project}
datasetId: ${test.datasetId}
tableId: ${test.tableId}
policyData: ${admin.policyData}
variables:
admin:
fn::invoke:
function: gcp:organizations:getIAMPolicy
arguments:
bindings:
- role: roles/bigquery.dataOwner
members:
- user:jane@example.com
The IamPolicy resource is authoritative: it replaces the complete access policy for the table. The policyData comes from the getIAMPolicy data source, which defines bindings (role-to-members mappings). The datasetId and tableId properties identify which table receives the policy. This approach gives you full control but removes any permissions not explicitly listed.
Grant a role to multiple members at once
Teams often need to grant the same role to several users simultaneously, such as giving analysts read access.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const binding = new gcp.bigquery.IamBinding("binding", {
project: test.project,
datasetId: test.datasetId,
tableId: test.tableId,
role: "roles/bigquery.dataOwner",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
binding = gcp.bigquery.IamBinding("binding",
project=test["project"],
dataset_id=test["datasetId"],
table_id=test["tableId"],
role="roles/bigquery.dataOwner",
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 {
_, err := bigquery.NewIamBinding(ctx, "binding", &bigquery.IamBindingArgs{
Project: pulumi.Any(test.Project),
DatasetId: pulumi.Any(test.DatasetId),
TableId: pulumi.Any(test.TableId),
Role: pulumi.String("roles/bigquery.dataOwner"),
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 binding = new Gcp.BigQuery.IamBinding("binding", new()
{
Project = test.Project,
DatasetId = test.DatasetId,
TableId = test.TableId,
Role = "roles/bigquery.dataOwner",
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.IamBinding;
import com.pulumi.gcp.bigquery.IamBindingArgs;
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 binding = new IamBinding("binding", IamBindingArgs.builder()
.project(test.project())
.datasetId(test.datasetId())
.tableId(test.tableId())
.role("roles/bigquery.dataOwner")
.members("user:jane@example.com")
.build());
}
}
resources:
binding:
type: gcp:bigquery:IamBinding
properties:
project: ${test.project}
datasetId: ${test.datasetId}
tableId: ${test.tableId}
role: roles/bigquery.dataOwner
members:
- user:jane@example.com
The IamBinding resource is authoritative for a single role: it sets the complete member list for that role while preserving other roles on the table. The members property accepts a list of identities (users, service accounts, groups). This approach lets you manage one role’s membership without affecting other roles.
Add a single member to a role
When onboarding individual users, you can add one member to a role without modifying existing members.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const member = new gcp.bigquery.IamMember("member", {
project: test.project,
datasetId: test.datasetId,
tableId: test.tableId,
role: "roles/bigquery.dataOwner",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
member = gcp.bigquery.IamMember("member",
project=test["project"],
dataset_id=test["datasetId"],
table_id=test["tableId"],
role="roles/bigquery.dataOwner",
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 {
_, err := bigquery.NewIamMember(ctx, "member", &bigquery.IamMemberArgs{
Project: pulumi.Any(test.Project),
DatasetId: pulumi.Any(test.DatasetId),
TableId: pulumi.Any(test.TableId),
Role: pulumi.String("roles/bigquery.dataOwner"),
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 member = new Gcp.BigQuery.IamMember("member", new()
{
Project = test.Project,
DatasetId = test.DatasetId,
TableId = test.TableId,
Role = "roles/bigquery.dataOwner",
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.IamMember;
import com.pulumi.gcp.bigquery.IamMemberArgs;
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 member = new IamMember("member", IamMemberArgs.builder()
.project(test.project())
.datasetId(test.datasetId())
.tableId(test.tableId())
.role("roles/bigquery.dataOwner")
.member("user:jane@example.com")
.build());
}
}
resources:
member:
type: gcp:bigquery:IamMember
properties:
project: ${test.project}
datasetId: ${test.datasetId}
tableId: ${test.tableId}
role: roles/bigquery.dataOwner
member: user:jane@example.com
The IamMember resource is non-authoritative: it adds one member to a role without removing other members who already have that role. The member property takes a single identity string. This approach is safest when multiple teams manage access independently, since it won’t accidentally remove permissions granted elsewhere.
Beyond these examples
These snippets focus on specific IAM management approaches: authoritative policy replacement, role-level binding management, and individual member grants. They’re intentionally minimal rather than full access control systems.
The examples reference pre-existing infrastructure such as BigQuery datasets and tables. They focus on configuring access rather than provisioning the underlying data infrastructure.
To keep things focused, common IAM patterns are omitted, including:
- Project-level configuration (project property)
- Conditional IAM bindings
- Service account creation and management
- Cross-project or cross-organization access
These omissions are intentional: the goal is to illustrate how each IAM resource type is wired, not provide drop-in access control modules. See the BigQuery IamPolicy resource reference for all available configuration options.
Let's manage GCP BigQuery IAM Policies
Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.
Try Pulumi Cloud for FREEFrequently Asked Questions
Resource Selection & Conflicts
gcp.bigquery.IamPolicy is authoritative and replaces the entire IAM policy. gcp.bigquery.IamBinding is authoritative for a specific role, preserving other roles in the policy. gcp.bigquery.IamMember is non-authoritative, adding a single member while preserving other members for that role.gcp.bigquery.IamPolicy cannot be used with gcp.bigquery.IamBinding or gcp.bigquery.IamMember because they will conflict over policy control.Configuration & Setup
gcp.organizations.getIAMPolicy data source to generate policyData, then pass it to the gcp.bigquery.IamPolicy resource as shown in the examples.datasetId, tableId, and project properties are immutable and cannot be changed after the resource is created.