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 approaches: authoritative policy replacement (MetastoreTableIamPolicy), role-level member binding (MetastoreTableIamBinding), and incremental member addition (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 IAM principals.
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 entire policy. The policyData comes from the getIAMPolicy data source, which defines bindings (role-to-members mappings). The resource references the table via project, location, serviceId, databaseId, and table properties. This approach cannot be combined with MetastoreTableIamBinding or MetastoreTableIamMember, as they would conflict over policy ownership.
Grant a role to multiple members at once
Teams often need to grant the same role to several users or service accounts while preserving 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 but leaves other roles untouched. The members array lists all principals who should have the specified role. You can use multiple Binding resources for different roles, or combine Binding with Member resources as long as they don’t target the same role.
Add a single member to a role incrementally
When onboarding individual users or service accounts, you can add them to a role without affecting other members who already have that role.
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 removing existing members. The member property specifies a single principal (format: “user:email”, “serviceAccount:email”, “group:email”). This is the safest approach for incremental access grants, as it won’t disrupt existing permissions. You can combine multiple Member resources freely, even for the same role.
Beyond these examples
These snippets focus on specific IAM management approaches: authoritative policy replacement, role-level binding management, and incremental member addition. They’re intentionally minimal rather than full access control configurations.
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 permissions rather than provisioning the Metastore infrastructure.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition blocks)
- Custom role definitions
- Policy retrieval via data sources
- Combining Binding and Member resources safely
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 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 Selection & Conflicts
MetastoreTableIamPolicy is authoritative and replaces the entire IAM policy. MetastoreTableIamBinding is authoritative for a specific role, preserving other roles. MetastoreTableIamMember is non-authoritative, adding individual members while preserving existing ones.MetastoreTableIamPolicy cannot be used with MetastoreTableIamBinding or MetastoreTableIamMember because they will conflict over the policy state.Configuration & Setup
gcp.organizations.getIAMPolicy to generate policyData, then provide project, location, serviceId, databaseId, and table identifiers to the resource.project, location, serviceId, databaseId, table, role, and a list of members (e.g., ["user:jane@example.com"]).project, location, serviceId, databaseId, table, role, and a single member (e.g., "user:jane@example.com").databaseId, location, serviceId, table, project) are immutable and cannot be changed after creation.Import & Migration
You can use four formats:
- Full path:
projects/{{project}}/locations/{{location}}/services/{{serviceId}}/databases/{{databaseId}}/tables/{{name}} - Project-scoped:
{{project}}/{{location}}/{{serviceId}}/{{databaseId}}/{{name}} - Location-scoped:
{{location}}/{{serviceId}}/{{databaseId}}/{{name}} - Name only:
{{name}}
Missing values are taken from the provider configuration.