Manage GCP Dataproc Metastore Service IAM Bindings

The gcp:dataproc/metastoreServiceIamBinding:MetastoreServiceIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for Dataproc Metastore services, controlling which identities can access the service. This guide focuses on three capabilities: granting roles to multiple members, adding individual members incrementally, and replacing entire IAM policies.

IAM management for Metastore services comes in three forms: Policy (authoritative for all roles), Binding (authoritative for one role), and Member (non-authoritative for one identity). Policy cannot be used with Binding or Member; they will conflict. The examples are intentionally small. Combine them with your own Metastore services and identity management strategy.

Grant a role to multiple members at once

When onboarding a team or configuring service-to-service access, you often need to assign the same role to multiple identities simultaneously.

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 Binding resource is authoritative for the specified role. The members array lists all identities that should have this role; any existing members not in this list are removed. The role property accepts predefined roles like “roles/viewer” or custom roles in the format “[projects|organizations]/{parent-name}/roles/{role-name}”. The serviceId, location, and project properties identify which Metastore service to configure.

Add a single member to a role incrementally

When you need to grant access to one user without affecting others who already have the same role, the Member resource adds that identity without replacing the existing member list.

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 resource is non-authoritative. It adds one identity to a role without removing other members. The member property specifies a single identity using formats like “user:jane@example.com”, “serviceAccount:{email}”, or “group:{email}”. Multiple Member resources can target the same role without conflict, unlike Binding resources.

Replace the entire IAM policy with a new definition

Organizations with strict access control requirements sometimes need to define 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 Policy resource is fully authoritative. It replaces the entire IAM policy with the bindings defined in policyData. The getIAMPolicy data source constructs the policy document from a bindings array. This approach cannot coexist with Binding or Member resources; they will fight over policy state. Use Policy when you need complete control over all roles and members.

Beyond these examples

These snippets focus on specific IAM binding features: role-based access control and incremental vs authoritative policy management. They’re intentionally minimal rather than full access control configurations.

The examples reference pre-existing infrastructure such as Dataproc Metastore service instances. They focus on configuring IAM bindings rather than provisioning the Metastore services themselves.

To keep things focused, common IAM patterns are omitted, including:

  • Conditional IAM bindings (condition property)
  • Custom role definitions and formatting
  • Project and location inference from provider 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 Binding resource reference for all available configuration options.

Let's manage GCP Dataproc Metastore Service IAM Bindings

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Resource Selection & Conflicts
Which IAM resources can I use together?
MetastoreServiceIamPolicy cannot be used with MetastoreServiceIamBinding or MetastoreServiceIamMember because they will conflict. However, you can use MetastoreServiceIamBinding and MetastoreServiceIamMember together as long as they don’t grant privileges to the same role.
Which IAM resource should I use for managing Metastore permissions?

Choose based on your needs:

  • MetastoreServiceIamPolicy: Authoritative control (replaces entire policy)
  • MetastoreServiceIamBinding: Authoritative per role (preserves other roles)
  • MetastoreServiceIamMember: Non-authoritative (adds individual members, preserves existing)
IAM Configuration
How do I specify custom roles?
Custom roles must use the full format [projects|organizations]/{parent-name}/roles/{role-name}. For example, projects/my-project/roles/my-custom-role or organizations/my-org/roles/my-custom-role.
What member identity formats are supported?

Supported formats include:

  • allUsers or allAuthenticatedUsers (special identifiers)
  • user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}
  • projectOwner:projectid, projectEditor:projectid, projectViewer:projectid
  • Federated identities: principal://iam.googleapis.com/...
Resource Properties
What's the default location for Metastore IAM resources?
The default location is global. If not specified, the location is parsed from the parent resource identifier or taken from the provider configuration.

Using a different cloud?

Explore security guides for other cloud providers: