The gcp:dataproc/metastoreTableIamPolicy:MetastoreTableIamPolicy resource, part of the Pulumi GCP provider, manages IAM access control for Dataproc Metastore tables. This guide focuses on three capabilities: authoritative policy replacement (MetastoreTableIamPolicy), role-level member binding (MetastoreTableIamBinding), and incremental member grants (MetastoreTableIamMember).
These resources reference an existing Dataproc Metastore service, database, and table. The examples are intentionally small. Combine them with your own Metastore infrastructure and access requirements. Note that MetastoreTableIamPolicy cannot be used alongside MetastoreTableIamBinding or MetastoreTableIamMember, as they will conflict over policy ownership.
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/viewer",
members: ["user:jane@example.com"],
}],
});
const policy = new gcp.dataproc.MetastoreTableIamPolicy("policy", {
project: dpmsService.project,
location: dpmsService.location,
serviceId: dpmsService.serviceId,
databaseId: hive.hiveConfig[0].properties.database,
table: hive.hiveConfig[0].properties.table,
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.MetastoreTableIamPolicy("policy",
project=dpms_service["project"],
location=dpms_service["location"],
service_id=dpms_service["serviceId"],
database_id=hive["hiveConfig"][0]["properties"]["database"],
table=hive["hiveConfig"][0]["properties"]["table"],
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.NewMetastoreTableIamPolicy(ctx, "policy", &dataproc.MetastoreTableIamPolicyArgs{
Project: pulumi.Any(dpmsService.Project),
Location: pulumi.Any(dpmsService.Location),
ServiceId: pulumi.Any(dpmsService.ServiceId),
DatabaseId: pulumi.Any(hive.HiveConfig[0].Properties.Database),
Table: pulumi.Any(hive.HiveConfig[0].Properties.Table),
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.MetastoreTableIamPolicy("policy", new()
{
Project = dpmsService.Project,
Location = dpmsService.Location,
ServiceId = dpmsService.ServiceId,
DatabaseId = hive.HiveConfig[0].Properties.Database,
Table = hive.HiveConfig[0].Properties.Table,
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.MetastoreTableIamPolicy;
import com.pulumi.gcp.dataproc.MetastoreTableIamPolicyArgs;
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 MetastoreTableIamPolicy("policy", MetastoreTableIamPolicyArgs.builder()
.project(dpmsService.project())
.location(dpmsService.location())
.serviceId(dpmsService.serviceId())
.databaseId(hive.hiveConfig()[0].properties().database())
.table(hive.hiveConfig()[0].properties().table())
.policyData(admin.policyData())
.build());
}
}
resources:
policy:
type: gcp:dataproc:MetastoreTableIamPolicy
properties:
project: ${dpmsService.project}
location: ${dpmsService.location}
serviceId: ${dpmsService.serviceId}
databaseId: ${hive.hiveConfig[0].properties.database}
table: ${hive.hiveConfig[0].properties.table}
policyData: ${admin.policyData}
variables:
admin:
fn::invoke:
function: gcp:organizations:getIAMPolicy
arguments:
bindings:
- role: roles/viewer
members:
- user:jane@example.com
MetastoreTableIamPolicy is authoritative: it replaces the complete IAM policy for the table. The policyData comes from the getIAMPolicy data source, which defines bindings (role-to-members mappings). The resource requires project, location, serviceId, databaseId, and table to identify which Metastore table to manage. This approach gives you full control but requires declaring all access in one place.
Grant a role to multiple members at once
Teams often need to grant the same role to several users without affecting other roles already assigned to the table.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const binding = new gcp.dataproc.MetastoreTableIamBinding("binding", {
project: dpmsService.project,
location: dpmsService.location,
serviceId: dpmsService.serviceId,
databaseId: hive.hiveConfig[0].properties.database,
table: hive.hiveConfig[0].properties.table,
role: "roles/viewer",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
binding = gcp.dataproc.MetastoreTableIamBinding("binding",
project=dpms_service["project"],
location=dpms_service["location"],
service_id=dpms_service["serviceId"],
database_id=hive["hiveConfig"][0]["properties"]["database"],
table=hive["hiveConfig"][0]["properties"]["table"],
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.NewMetastoreTableIamBinding(ctx, "binding", &dataproc.MetastoreTableIamBindingArgs{
Project: pulumi.Any(dpmsService.Project),
Location: pulumi.Any(dpmsService.Location),
ServiceId: pulumi.Any(dpmsService.ServiceId),
DatabaseId: pulumi.Any(hive.HiveConfig[0].Properties.Database),
Table: pulumi.Any(hive.HiveConfig[0].Properties.Table),
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.MetastoreTableIamBinding("binding", new()
{
Project = dpmsService.Project,
Location = dpmsService.Location,
ServiceId = dpmsService.ServiceId,
DatabaseId = hive.HiveConfig[0].Properties.Database,
Table = hive.HiveConfig[0].Properties.Table,
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.MetastoreTableIamBinding;
import com.pulumi.gcp.dataproc.MetastoreTableIamBindingArgs;
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 MetastoreTableIamBinding("binding", MetastoreTableIamBindingArgs.builder()
.project(dpmsService.project())
.location(dpmsService.location())
.serviceId(dpmsService.serviceId())
.databaseId(hive.hiveConfig()[0].properties().database())
.table(hive.hiveConfig()[0].properties().table())
.role("roles/viewer")
.members("user:jane@example.com")
.build());
}
}
resources:
binding:
type: gcp:dataproc:MetastoreTableIamBinding
properties:
project: ${dpmsService.project}
location: ${dpmsService.location}
serviceId: ${dpmsService.serviceId}
databaseId: ${hive.hiveConfig[0].properties.database}
table: ${hive.hiveConfig[0].properties.table}
role: roles/viewer
members:
- user:jane@example.com
MetastoreTableIamBinding 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 takes an array of identities (users, service accounts, groups). This approach lets you manage one role’s membership without declaring the entire policy, making it easier to coordinate with other teams managing different roles.
Add a single member to a role incrementally
When onboarding individual users, you can add them to a role without declaring the complete member list.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const member = new gcp.dataproc.MetastoreTableIamMember("member", {
project: dpmsService.project,
location: dpmsService.location,
serviceId: dpmsService.serviceId,
databaseId: hive.hiveConfig[0].properties.database,
table: hive.hiveConfig[0].properties.table,
role: "roles/viewer",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
member = gcp.dataproc.MetastoreTableIamMember("member",
project=dpms_service["project"],
location=dpms_service["location"],
service_id=dpms_service["serviceId"],
database_id=hive["hiveConfig"][0]["properties"]["database"],
table=hive["hiveConfig"][0]["properties"]["table"],
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.NewMetastoreTableIamMember(ctx, "member", &dataproc.MetastoreTableIamMemberArgs{
Project: pulumi.Any(dpmsService.Project),
Location: pulumi.Any(dpmsService.Location),
ServiceId: pulumi.Any(dpmsService.ServiceId),
DatabaseId: pulumi.Any(hive.HiveConfig[0].Properties.Database),
Table: pulumi.Any(hive.HiveConfig[0].Properties.Table),
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.MetastoreTableIamMember("member", new()
{
Project = dpmsService.Project,
Location = dpmsService.Location,
ServiceId = dpmsService.ServiceId,
DatabaseId = hive.HiveConfig[0].Properties.Database,
Table = hive.HiveConfig[0].Properties.Table,
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.MetastoreTableIamMember;
import com.pulumi.gcp.dataproc.MetastoreTableIamMemberArgs;
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 MetastoreTableIamMember("member", MetastoreTableIamMemberArgs.builder()
.project(dpmsService.project())
.location(dpmsService.location())
.serviceId(dpmsService.serviceId())
.databaseId(hive.hiveConfig()[0].properties().database())
.table(hive.hiveConfig()[0].properties().table())
.role("roles/viewer")
.member("user:jane@example.com")
.build());
}
}
resources:
member:
type: gcp:dataproc:MetastoreTableIamMember
properties:
project: ${dpmsService.project}
location: ${dpmsService.location}
serviceId: ${dpmsService.serviceId}
databaseId: ${hive.hiveConfig[0].properties.database}
table: ${hive.hiveConfig[0].properties.table}
role: roles/viewer
member: user:jane@example.com
MetastoreTableIamMember is non-authoritative: it adds one member to a role without affecting other members already granted that role. The member property takes a single identity. This is the most granular approach, useful when multiple teams or processes need to grant access independently. You can use multiple MetastoreTableIamMember resources for the same role, and they won’t conflict with each other.
Beyond these examples
These snippets focus on specific IAM management approaches: authoritative policy replacement, role-level binding management, and incremental member grants. They’re intentionally minimal rather than complete access control solutions.
The examples reference pre-existing infrastructure such as Dataproc Metastore service (serviceId), Hive database and table (databaseId, table), and GCP project and location. They focus on configuring IAM bindings rather than provisioning the Metastore infrastructure itself.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition blocks)
- Custom role definitions
- Policy conflict resolution strategies
- Audit logging configuration
These omissions are intentional: the goal is to illustrate how each IAM management approach is wired, not provide drop-in access control modules. See the Dataproc Metastore Table IAM Policy resource reference for all available configuration options.
Let's manage GCP Dataproc Metastore Table 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 Conflicts & Compatibility
MetastoreTableIamPolicy cannot be used with MetastoreTableIamBinding or MetastoreTableIamMember because they will conflict over policy control. Use MetastoreTableIamPolicy alone, or use Binding/Member resources without Policy.Resource Selection & Configuration
MetastoreTableIamPolicy is authoritative and replaces the entire IAM policy. MetastoreTableIamBinding is authoritative for a specific role, preserving other roles. MetastoreTableIamMember is non-authoritative, adding a single member while preserving other members for that role.gcp.organizations.getIAMPolicy data source with your desired bindings, then pass its policyData output to the MetastoreTableIamPolicy resource.databaseId, location, project, serviceId, table) are immutable and require resource replacement if changed.