Manage GCP Dataproc Metastore Database IAM Bindings

The gcp:dataproc/metastoreDatabaseIamBinding:MetastoreDatabaseIamBinding resource, part of the Pulumi GCP provider, manages IAM permissions for Dataproc Metastore databases by granting roles to members. This guide focuses on three capabilities: granting roles to multiple members, adding individual members incrementally, and replacing complete IAM policies.

Three related resources manage Metastore database IAM: MetastoreDatabaseIamPolicy (replaces the entire policy), MetastoreDatabaseIamBinding (authoritative for one role), and MetastoreDatabaseIamMember (non-authoritative, adds one member). The examples are intentionally small. Combine them with your own Metastore infrastructure and identity management.

Grant a role to multiple members at once

When onboarding teams or granting read access to analytics tools, you often need to grant the same role to multiple identities simultaneously.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const binding = new gcp.dataproc.MetastoreDatabaseIamBinding("binding", {
    project: dpmsService.project,
    location: dpmsService.location,
    serviceId: dpmsService.serviceId,
    database: hive.hiveConfig[0].properties.database,
    role: "roles/viewer",
    members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp

binding = gcp.dataproc.MetastoreDatabaseIamBinding("binding",
    project=dpms_service["project"],
    location=dpms_service["location"],
    service_id=dpms_service["serviceId"],
    database=hive["hiveConfig"][0]["properties"]["database"],
    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.NewMetastoreDatabaseIamBinding(ctx, "binding", &dataproc.MetastoreDatabaseIamBindingArgs{
			Project:   pulumi.Any(dpmsService.Project),
			Location:  pulumi.Any(dpmsService.Location),
			ServiceId: pulumi.Any(dpmsService.ServiceId),
			Database:  pulumi.Any(hive.HiveConfig[0].Properties.Database),
			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.MetastoreDatabaseIamBinding("binding", new()
    {
        Project = dpmsService.Project,
        Location = dpmsService.Location,
        ServiceId = dpmsService.ServiceId,
        Database = hive.HiveConfig[0].Properties.Database,
        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.MetastoreDatabaseIamBinding;
import com.pulumi.gcp.dataproc.MetastoreDatabaseIamBindingArgs;
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 MetastoreDatabaseIamBinding("binding", MetastoreDatabaseIamBindingArgs.builder()
            .project(dpmsService.project())
            .location(dpmsService.location())
            .serviceId(dpmsService.serviceId())
            .database(hive.hiveConfig()[0].properties().database())
            .role("roles/viewer")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  binding:
    type: gcp:dataproc:MetastoreDatabaseIamBinding
    properties:
      project: ${dpmsService.project}
      location: ${dpmsService.location}
      serviceId: ${dpmsService.serviceId}
      database: ${hive.hiveConfig[0].properties.database}
      role: roles/viewer
      members:
        - user:jane@example.com

The binding resource is authoritative for the specified role: it sets the complete list of members who have that role. The members array accepts users, service accounts, groups, and special identifiers like allUsers. Other roles on the database remain unchanged.

Add a single member to a role incrementally

To grant access to individual users without affecting existing permissions, use the non-authoritative member resource.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const member = new gcp.dataproc.MetastoreDatabaseIamMember("member", {
    project: dpmsService.project,
    location: dpmsService.location,
    serviceId: dpmsService.serviceId,
    database: hive.hiveConfig[0].properties.database,
    role: "roles/viewer",
    member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp

member = gcp.dataproc.MetastoreDatabaseIamMember("member",
    project=dpms_service["project"],
    location=dpms_service["location"],
    service_id=dpms_service["serviceId"],
    database=hive["hiveConfig"][0]["properties"]["database"],
    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.NewMetastoreDatabaseIamMember(ctx, "member", &dataproc.MetastoreDatabaseIamMemberArgs{
			Project:   pulumi.Any(dpmsService.Project),
			Location:  pulumi.Any(dpmsService.Location),
			ServiceId: pulumi.Any(dpmsService.ServiceId),
			Database:  pulumi.Any(hive.HiveConfig[0].Properties.Database),
			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.MetastoreDatabaseIamMember("member", new()
    {
        Project = dpmsService.Project,
        Location = dpmsService.Location,
        ServiceId = dpmsService.ServiceId,
        Database = hive.HiveConfig[0].Properties.Database,
        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.MetastoreDatabaseIamMember;
import com.pulumi.gcp.dataproc.MetastoreDatabaseIamMemberArgs;
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 MetastoreDatabaseIamMember("member", MetastoreDatabaseIamMemberArgs.builder()
            .project(dpmsService.project())
            .location(dpmsService.location())
            .serviceId(dpmsService.serviceId())
            .database(hive.hiveConfig()[0].properties().database())
            .role("roles/viewer")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  member:
    type: gcp:dataproc:MetastoreDatabaseIamMember
    properties:
      project: ${dpmsService.project}
      location: ${dpmsService.location}
      serviceId: ${dpmsService.serviceId}
      database: ${hive.hiveConfig[0].properties.database}
      role: roles/viewer
      member: user:jane@example.com

The member resource adds one identity to a role without replacing existing members. Multiple member resources can target the same role, and they won’t conflict with each other. This approach works well for incremental access grants where you don’t want to manage the complete member list.

Replace the entire IAM policy with a new definition

Organizations with strict security requirements sometimes need to define the complete IAM policy from scratch, ensuring a known state.

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.MetastoreDatabaseIamPolicy("policy", {
    project: dpmsService.project,
    location: dpmsService.location,
    serviceId: dpmsService.serviceId,
    database: hive.hiveConfig[0].properties.database,
    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.MetastoreDatabaseIamPolicy("policy",
    project=dpms_service["project"],
    location=dpms_service["location"],
    service_id=dpms_service["serviceId"],
    database=hive["hiveConfig"][0]["properties"]["database"],
    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.NewMetastoreDatabaseIamPolicy(ctx, "policy", &dataproc.MetastoreDatabaseIamPolicyArgs{
			Project:    pulumi.Any(dpmsService.Project),
			Location:   pulumi.Any(dpmsService.Location),
			ServiceId:  pulumi.Any(dpmsService.ServiceId),
			Database:   pulumi.Any(hive.HiveConfig[0].Properties.Database),
			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.MetastoreDatabaseIamPolicy("policy", new()
    {
        Project = dpmsService.Project,
        Location = dpmsService.Location,
        ServiceId = dpmsService.ServiceId,
        Database = hive.HiveConfig[0].Properties.Database,
        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.MetastoreDatabaseIamPolicy;
import com.pulumi.gcp.dataproc.MetastoreDatabaseIamPolicyArgs;
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 MetastoreDatabaseIamPolicy("policy", MetastoreDatabaseIamPolicyArgs.builder()
            .project(dpmsService.project())
            .location(dpmsService.location())
            .serviceId(dpmsService.serviceId())
            .database(hive.hiveConfig()[0].properties().database())
            .policyData(admin.policyData())
            .build());

    }
}
resources:
  policy:
    type: gcp:dataproc:MetastoreDatabaseIamPolicy
    properties:
      project: ${dpmsService.project}
      location: ${dpmsService.location}
      serviceId: ${dpmsService.serviceId}
      database: ${hive.hiveConfig[0].properties.database}
      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 all existing IAM bindings on the database. The policyData comes from the getIAMPolicy data source, which constructs a policy document from bindings. Use this approach when you need complete control over all permissions, but be aware it removes any bindings not defined in your configuration.

Beyond these examples

These snippets focus on specific IAM management features: role-based access control (binding vs member) and complete policy replacement. They’re intentionally minimal rather than full access control solutions.

The examples reference pre-existing infrastructure such as Dataproc Metastore service and database, and user accounts, service accounts, or groups to grant access to. They focus on configuring IAM permissions rather than provisioning the Metastore infrastructure itself.

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

  • Conditional IAM bindings (condition property)
  • Custom role definitions and formatting
  • Federated identity configuration
  • Policy conflict resolution between resource types

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 Metastore Database IAM Binding resource reference for all available configuration options.

Let's manage GCP Dataproc Metastore Database 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
What's the difference between IamPolicy, IamBinding, and IamMember resources?
MetastoreDatabaseIamPolicy is fully authoritative and replaces the entire IAM policy. MetastoreDatabaseIamBinding is authoritative for a specific role, managing all members for that role while preserving other roles. MetastoreDatabaseIamMember is non-authoritative, adding individual members without affecting other members for the same role.
Can I use IamPolicy together with IamBinding or IamMember?
No, MetastoreDatabaseIamPolicy cannot be used with MetastoreDatabaseIamBinding or MetastoreDatabaseIamMember as they will conflict over the policy configuration.
Can I use IamBinding and IamMember together?
Yes, but only if they manage different roles. Using MetastoreDatabaseIamBinding and MetastoreDatabaseIamMember for the same role will cause conflicts.
Configuration & Identity Formats
What member identity formats are supported?
The members property supports multiple formats including allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, project-scoped identities (projectOwner:, projectEditor:, projectViewer:), and federated identities using the principal:// format.
How do I specify custom IAM roles?
Custom roles must use the format [projects|organizations]/{parent-name}/roles/{role-name} in the role property.

Using a different cloud?

Explore security guides for other cloud providers: