The gcp:dataproc/metastoreServiceIamMember:MetastoreServiceIamMember resource, part of the Pulumi GCP provider, grants IAM permissions on Dataproc Metastore services by adding individual members to roles. This guide focuses on three capabilities: single-member role grants, multi-member role bindings, and complete policy replacement.
IAM resources reference existing Metastore services and require valid project, location, and serviceId identifiers. The examples are intentionally small. Combine them with your own Metastore services and identity management.
Grant a role to a single user
Most IAM configurations add a specific role to one user or service account without affecting other members.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const member = new gcp.dataproc.MetastoreServiceIamMember("member", {
project: _default.project,
location: _default.location,
serviceId: _default.serviceId,
role: "roles/viewer",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
member = gcp.dataproc.MetastoreServiceIamMember("member",
project=default["project"],
location=default["location"],
service_id=default["serviceId"],
role="roles/viewer",
member="user:jane@example.com")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/dataproc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := dataproc.NewMetastoreServiceIamMember(ctx, "member", &dataproc.MetastoreServiceIamMemberArgs{
Project: pulumi.Any(_default.Project),
Location: pulumi.Any(_default.Location),
ServiceId: pulumi.Any(_default.ServiceId),
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.Dataproc.MetastoreServiceIamMember("member", new()
{
Project = @default.Project,
Location = @default.Location,
ServiceId = @default.ServiceId,
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.dataproc.MetastoreServiceIamMember;
import com.pulumi.gcp.dataproc.MetastoreServiceIamMemberArgs;
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 MetastoreServiceIamMember("member", MetastoreServiceIamMemberArgs.builder()
.project(default_.project())
.location(default_.location())
.serviceId(default_.serviceId())
.role("roles/viewer")
.member("user:jane@example.com")
.build());
}
}
resources:
member:
type: gcp:dataproc:MetastoreServiceIamMember
properties:
project: ${default.project}
location: ${default.location}
serviceId: ${default.serviceId}
role: roles/viewer
member: user:jane@example.com
The member property specifies the identity receiving permissions (user, service account, group, or domain). The role property defines the permissions being granted. This resource is non-authoritative: it adds the member to the role without removing other members who already have access. The serviceId, project, and location properties identify which Metastore service receives the binding.
Grant a role to multiple members at once
When multiple users or service accounts need the same permissions, binding them together ensures they’re managed as a group.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const binding = new gcp.dataproc.MetastoreServiceIamBinding("binding", {
project: _default.project,
location: _default.location,
serviceId: _default.serviceId,
role: "roles/viewer",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
binding = gcp.dataproc.MetastoreServiceIamBinding("binding",
project=default["project"],
location=default["location"],
service_id=default["serviceId"],
role="roles/viewer",
members=["user:jane@example.com"])
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/dataproc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := dataproc.NewMetastoreServiceIamBinding(ctx, "binding", &dataproc.MetastoreServiceIamBindingArgs{
Project: pulumi.Any(_default.Project),
Location: pulumi.Any(_default.Location),
ServiceId: pulumi.Any(_default.ServiceId),
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.Dataproc.MetastoreServiceIamBinding("binding", new()
{
Project = @default.Project,
Location = @default.Location,
ServiceId = @default.ServiceId,
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.dataproc.MetastoreServiceIamBinding;
import com.pulumi.gcp.dataproc.MetastoreServiceIamBindingArgs;
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 MetastoreServiceIamBinding("binding", MetastoreServiceIamBindingArgs.builder()
.project(default_.project())
.location(default_.location())
.serviceId(default_.serviceId())
.role("roles/viewer")
.members("user:jane@example.com")
.build());
}
}
resources:
binding:
type: gcp:dataproc:MetastoreServiceIamBinding
properties:
project: ${default.project}
location: ${default.location}
serviceId: ${default.serviceId}
role: roles/viewer
members:
- user:jane@example.com
The members property takes a list of identities that will all receive the specified role. This resource is authoritative for the role: it defines the complete member list, replacing any previous bindings for that role while preserving other roles on the service. Use MetastoreServiceIamBinding when you want to manage all members for a role together, rather than adding them individually.
Replace the entire IAM policy
Some workflows require setting the complete IAM policy from scratch, replacing any existing bindings.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const admin = gcp.organizations.getIAMPolicy({
bindings: [{
role: "roles/viewer",
members: ["user:jane@example.com"],
}],
});
const policy = new gcp.dataproc.MetastoreServiceIamPolicy("policy", {
project: _default.project,
location: _default.location,
serviceId: _default.serviceId,
policyData: admin.then(admin => admin.policyData),
});
import pulumi
import pulumi_gcp as gcp
admin = gcp.organizations.get_iam_policy(bindings=[{
"role": "roles/viewer",
"members": ["user:jane@example.com"],
}])
policy = gcp.dataproc.MetastoreServiceIamPolicy("policy",
project=default["project"],
location=default["location"],
service_id=default["serviceId"],
policy_data=admin.policy_data)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/dataproc"
"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/viewer",
Members: []string{
"user:jane@example.com",
},
},
},
}, nil)
if err != nil {
return err
}
_, err = dataproc.NewMetastoreServiceIamPolicy(ctx, "policy", &dataproc.MetastoreServiceIamPolicyArgs{
Project: pulumi.Any(_default.Project),
Location: pulumi.Any(_default.Location),
ServiceId: pulumi.Any(_default.ServiceId),
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/viewer",
Members = new[]
{
"user:jane@example.com",
},
},
},
});
var policy = new Gcp.Dataproc.MetastoreServiceIamPolicy("policy", new()
{
Project = @default.Project,
Location = @default.Location,
ServiceId = @default.ServiceId,
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.dataproc.MetastoreServiceIamPolicy;
import com.pulumi.gcp.dataproc.MetastoreServiceIamPolicyArgs;
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/viewer")
.members("user:jane@example.com")
.build())
.build());
var policy = new MetastoreServiceIamPolicy("policy", MetastoreServiceIamPolicyArgs.builder()
.project(default_.project())
.location(default_.location())
.serviceId(default_.serviceId())
.policyData(admin.policyData())
.build());
}
}
resources:
policy:
type: gcp:dataproc:MetastoreServiceIamPolicy
properties:
project: ${default.project}
location: ${default.location}
serviceId: ${default.serviceId}
policyData: ${admin.policyData}
variables:
admin:
fn::invoke:
function: gcp:organizations:getIAMPolicy
arguments:
bindings:
- role: roles/viewer
members:
- user:jane@example.com
The policyData property accepts a complete IAM policy document from the getIAMPolicy data source. The bindings array in the data source defines all roles and their members. This resource is fully authoritative: it replaces the entire IAM policy on the Metastore service. You cannot use MetastoreServiceIamPolicy alongside MetastoreServiceIamBinding or MetastoreServiceIamMember, as they will conflict over policy ownership.
Beyond these examples
These snippets focus on specific IAM management features: single-member grants, multi-member role bindings, and complete policy replacement. They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as Dataproc Metastore services (by serviceId), and GCP projects and locations. They focus on granting permissions rather than provisioning the underlying services.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Custom role definitions
- Service account creation
- Federated identity configuration
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 Dataproc Metastore Service IAM Member resource reference for all available configuration options.
Let's manage GCP Dataproc Metastore Service IAM Access
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 management style:
MetastoreServiceIamPolicyfor full control (replaces entire policy)MetastoreServiceIamBindingto manage all members for a specific roleMetastoreServiceIamMemberto add individual members without affecting others
MetastoreServiceIamPolicy cannot be used with MetastoreServiceIamBinding or MetastoreServiceIamMember because they will conflict over the policy configuration.Identity & Role Configuration
The member field supports:
allUsers(anyone on the internet)allAuthenticatedUsers(anyone with a Google account)user:{email}(specific Google account)serviceAccount:{email}(service account)group:{email}(Google group)domain:{domain}(all users in a G Suite domain)projectOwner/Editor/Viewer:{projectid}(project role holders)- Federated identities (workload/workforce identity pools)
[projects|organizations]/{parent-name}/roles/{role-name}, for example: projects/my-project/roles/my-custom-role.MetastoreServiceIamMember with the member field set to the user’s identity, such as user:jane@example.com.MetastoreServiceIamBinding with the members array containing all user identities for that role.Resource Management
member, role, serviceId, location, project) are immutable and require resource replacement if changed.global. You can override this by setting the location property or parsing it from the parent resource identifier.