The gcp:bigquerydatapolicy/dataPolicyIamBinding:DataPolicyIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for BigQuery data policies by granting a specific role to a list of members. This guide focuses on two capabilities: granting roles to multiple members simultaneously and adding individual members incrementally.
IAM bindings reference existing BigQuery data policies and require project and location configuration. The examples are intentionally small. Combine them with your own data policy resources and access control requirements.
Grant a role to multiple members at once
Teams managing data policies often need to grant the same role to multiple users or service accounts, such as giving viewer access to an analytics team.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const binding = new gcp.bigquerydatapolicy.DataPolicyIamBinding("binding", {
project: dataPolicy.project,
location: dataPolicy.location,
dataPolicyId: dataPolicy.dataPolicyId,
role: "roles/viewer",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
binding = gcp.bigquerydatapolicy.DataPolicyIamBinding("binding",
project=data_policy["project"],
location=data_policy["location"],
data_policy_id=data_policy["dataPolicyId"],
role="roles/viewer",
members=["user:jane@example.com"])
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/bigquerydatapolicy"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := bigquerydatapolicy.NewDataPolicyIamBinding(ctx, "binding", &bigquerydatapolicy.DataPolicyIamBindingArgs{
Project: pulumi.Any(dataPolicy.Project),
Location: pulumi.Any(dataPolicy.Location),
DataPolicyId: pulumi.Any(dataPolicy.DataPolicyId),
Role: pulumi.String("roles/viewer"),
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.BigQueryDataPolicy.DataPolicyIamBinding("binding", new()
{
Project = dataPolicy.Project,
Location = dataPolicy.Location,
DataPolicyId = dataPolicy.DataPolicyId,
Role = "roles/viewer",
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.bigquerydatapolicy.DataPolicyIamBinding;
import com.pulumi.gcp.bigquerydatapolicy.DataPolicyIamBindingArgs;
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 DataPolicyIamBinding("binding", DataPolicyIamBindingArgs.builder()
.project(dataPolicy.project())
.location(dataPolicy.location())
.dataPolicyId(dataPolicy.dataPolicyId())
.role("roles/viewer")
.members("user:jane@example.com")
.build());
}
}
resources:
binding:
type: gcp:bigquerydatapolicy:DataPolicyIamBinding
properties:
project: ${dataPolicy.project}
location: ${dataPolicy.location}
dataPolicyId: ${dataPolicy.dataPolicyId}
role: roles/viewer
members:
- user:jane@example.com
The DataPolicyIamBinding resource is authoritative for the specified role: it replaces the entire member list for that role while preserving other roles on the data policy. The members array accepts various identity formats including users, service accounts, groups, and domains. The dataPolicyId, location, and project properties identify which data policy receives the binding.
Add a single member to a role incrementally
When onboarding individual users, you can grant access without managing the full member list for a role.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const member = new gcp.bigquerydatapolicy.DataPolicyIamMember("member", {
project: dataPolicy.project,
location: dataPolicy.location,
dataPolicyId: dataPolicy.dataPolicyId,
role: "roles/viewer",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
member = gcp.bigquerydatapolicy.DataPolicyIamMember("member",
project=data_policy["project"],
location=data_policy["location"],
data_policy_id=data_policy["dataPolicyId"],
role="roles/viewer",
member="user:jane@example.com")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/bigquerydatapolicy"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := bigquerydatapolicy.NewDataPolicyIamMember(ctx, "member", &bigquerydatapolicy.DataPolicyIamMemberArgs{
Project: pulumi.Any(dataPolicy.Project),
Location: pulumi.Any(dataPolicy.Location),
DataPolicyId: pulumi.Any(dataPolicy.DataPolicyId),
Role: pulumi.String("roles/viewer"),
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.BigQueryDataPolicy.DataPolicyIamMember("member", new()
{
Project = dataPolicy.Project,
Location = dataPolicy.Location,
DataPolicyId = dataPolicy.DataPolicyId,
Role = "roles/viewer",
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.bigquerydatapolicy.DataPolicyIamMember;
import com.pulumi.gcp.bigquerydatapolicy.DataPolicyIamMemberArgs;
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 DataPolicyIamMember("member", DataPolicyIamMemberArgs.builder()
.project(dataPolicy.project())
.location(dataPolicy.location())
.dataPolicyId(dataPolicy.dataPolicyId())
.role("roles/viewer")
.member("user:jane@example.com")
.build());
}
}
resources:
member:
type: gcp:bigquerydatapolicy:DataPolicyIamMember
properties:
project: ${dataPolicy.project}
location: ${dataPolicy.location}
dataPolicyId: ${dataPolicy.dataPolicyId}
role: roles/viewer
member: user:jane@example.com
The DataPolicyIamMember resource is non-authoritative: it adds a single member to a role without affecting existing members. Use member (singular) instead of members (plural) to specify one identity. This approach works well for gradual access expansion or automated onboarding workflows where you don’t want to track all existing members.
Beyond these examples
These snippets focus on specific IAM binding features: role-based access control and batch and incremental member management. They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as BigQuery data policies (dataPolicyId references) and GCP project and location configuration. They focus on configuring IAM bindings rather than provisioning the underlying data policies.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Full policy replacement (DataPolicyIamPolicy resource)
- Custom role definitions and formatting
- Federated identity and workload identity pool configuration
These omissions are intentional: the goal is to illustrate how IAM bindings are wired, not provide drop-in access control modules. See the DataPolicyIamBinding resource reference for all available configuration options.
Let's manage GCP BigQuery Data Policy 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 Selection & Conflicts
Choose based on your needs:
gcp.bigquerydatapolicy.DataPolicyIamPolicy: Authoritative, replaces the entire IAM policygcp.bigquerydatapolicy.DataPolicyIamBinding: Authoritative for a specific role, preserves other rolesgcp.bigquerydatapolicy.DataPolicyIamMember: Non-authoritative, adds individual members while preserving existing ones
gcp.bigquerydatapolicy.DataPolicyIamPolicy cannot be used with gcp.bigquerydatapolicy.DataPolicyIamBinding or gcp.bigquerydatapolicy.DataPolicyIamMember because they will conflict over the policy state.Configuration & Identity Management
Supported identity formats include:
user:{emailid}: Specific Google account (e.g.,user:alice@gmail.com)serviceAccount:{emailid}: Service account (e.g.,serviceAccount:my-app@appspot.gserviceaccount.com)group:{emailid}: Google group (e.g.,group:admins@example.com)domain:{domain}: All users in a G Suite domain (e.g.,domain:example.com)allUsers: Anyone on the internetallAuthenticatedUsers: Anyone with a Google accountprojectOwner:projectid,projectEditor:projectid,projectViewer:projectid: Project-level roles- Federated identities: Workload/workforce identity pool principals (e.g.,
principal://iam.googleapis.com/...)
[projects|organizations]/{parent-name}/roles/{role-name}. For example, projects/my-project/roles/my-custom-role or organizations/my-org/roles/my-custom-role.dataPolicyId, location, project, role, and condition. Changes to these require recreating the resource.Advanced Configuration
location and project can be parsed from the parent resource identifier if not explicitly provided. If neither the parent identifier nor the property specifies them, they’re taken from the provider configuration.gcp.bigquerydatapolicy.DataPolicyIamBinding can be used per role. To add multiple members to a role, include them all in the members array of a single binding, or use gcp.bigquerydatapolicy.DataPolicyIamMember for individual member management.