Manage GCP Compute Disk IAM Bindings

The gcp:compute/diskIamBinding:DiskIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for Compute Engine disks by granting a specific role to a list of members. This guide focuses on two capabilities: granting roles to multiple members and adding individual members incrementally.

DiskIamBinding is authoritative for a given role, meaning it replaces all members for that role. It references existing Compute Engine disks and cannot be used with DiskIamPolicy (they conflict), but can work alongside DiskIamMember for different roles. The examples are intentionally small. Combine them with your own disk resources and identity management.

Grant a role to multiple members at once

Teams managing disk access often need to grant the same role to multiple users or service accounts simultaneously, such as giving viewer access to an entire team.

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

const binding = new gcp.compute.DiskIamBinding("binding", {
    project: _default.project,
    zone: _default.zone,
    name: _default.name,
    role: "roles/viewer",
    members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp

binding = gcp.compute.DiskIamBinding("binding",
    project=default["project"],
    zone=default["zone"],
    name=default["name"],
    role="roles/viewer",
    members=["user:jane@example.com"])
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewDiskIamBinding(ctx, "binding", &compute.DiskIamBindingArgs{
			Project: pulumi.Any(_default.Project),
			Zone:    pulumi.Any(_default.Zone),
			Name:    pulumi.Any(_default.Name),
			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.Compute.DiskIamBinding("binding", new()
    {
        Project = @default.Project,
        Zone = @default.Zone,
        Name = @default.Name,
        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.compute.DiskIamBinding;
import com.pulumi.gcp.compute.DiskIamBindingArgs;
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 DiskIamBinding("binding", DiskIamBindingArgs.builder()
            .project(default_.project())
            .zone(default_.zone())
            .name(default_.name())
            .role("roles/viewer")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  binding:
    type: gcp:compute:DiskIamBinding
    properties:
      project: ${default.project}
      zone: ${default.zone}
      name: ${default.name}
      role: roles/viewer
      members:
        - user:jane@example.com

The role property specifies which IAM role to grant (e.g., “roles/viewer”). The members array lists all identities that receive this role; DiskIamBinding replaces any existing members for this role on the disk. The name, zone, and project properties identify which disk to modify. Member identities follow GCP’s format: “user:email”, “serviceAccount:email”, “group:email”, or special identifiers like “allUsers”.

Add a single member to a role incrementally

When onboarding new team members or granting access to individual service accounts, you often need to add one member at a time without affecting existing permissions.

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

const member = new gcp.compute.DiskIamMember("member", {
    project: _default.project,
    zone: _default.zone,
    name: _default.name,
    role: "roles/viewer",
    member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp

member = gcp.compute.DiskIamMember("member",
    project=default["project"],
    zone=default["zone"],
    name=default["name"],
    role="roles/viewer",
    member="user:jane@example.com")
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewDiskIamMember(ctx, "member", &compute.DiskIamMemberArgs{
			Project: pulumi.Any(_default.Project),
			Zone:    pulumi.Any(_default.Zone),
			Name:    pulumi.Any(_default.Name),
			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.Compute.DiskIamMember("member", new()
    {
        Project = @default.Project,
        Zone = @default.Zone,
        Name = @default.Name,
        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.compute.DiskIamMember;
import com.pulumi.gcp.compute.DiskIamMemberArgs;
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 DiskIamMember("member", DiskIamMemberArgs.builder()
            .project(default_.project())
            .zone(default_.zone())
            .name(default_.name())
            .role("roles/viewer")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  member:
    type: gcp:compute:DiskIamMember
    properties:
      project: ${default.project}
      zone: ${default.zone}
      name: ${default.name}
      role: roles/viewer
      member: user:jane@example.com

DiskIamMember adds a single member to a role without replacing other members. The member property (singular) specifies one identity to add. This resource is non-authoritative: it preserves existing members for the role. Use DiskIamMember when you need to grant access incrementally; use DiskIamBinding when you want to define the complete member list for a role.

Beyond these examples

These snippets focus on specific disk IAM features: role-based access control and batch and incremental member management. They’re intentionally minimal rather than full access control configurations.

The examples reference pre-existing infrastructure such as Compute Engine disks in specified zones and a GCP project with appropriate IAM permissions. They focus on configuring IAM bindings rather than provisioning disks or managing broader access policies.

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

  • Conditional IAM bindings (condition property)
  • Custom role definitions and formatting
  • Policy-level management (DiskIamPolicy resource)
  • Cross-project or organization-level access

These omissions are intentional: the goal is to illustrate how disk IAM bindings are wired, not provide drop-in access control modules. See the Compute Disk IAM Binding resource reference for all available configuration options.

Let's manage GCP Compute Disk 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 DiskIamPolicy, DiskIamBinding, and DiskIamMember?
DiskIamPolicy is authoritative and replaces the entire IAM policy. DiskIamBinding is authoritative for a specific role, preserving other roles in the policy. DiskIamMember is non-authoritative, adding a single member to a role without affecting other members for that role.
Can I use these IAM resources together?
DiskIamPolicy cannot be used with DiskIamBinding or DiskIamMember because they’ll conflict over the policy. However, DiskIamBinding and DiskIamMember can be used together if they manage different roles.
Why am I seeing IAM policy conflicts?
Mixing DiskIamPolicy with DiskIamBinding or DiskIamMember causes conflicts. Similarly, using DiskIamBinding and DiskIamMember for the same role will fight over permissions. Choose one approach per role.
IAM Configuration
What member identity formats are supported?
You can use allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner:projectid, projectEditor:projectid, projectViewer:projectid, and federated identities like principal://iam.googleapis.com/....
How do I specify custom roles?
Custom roles must use the format [projects|organizations]/{parent-name}/roles/{role-name}, for example projects/my-project/roles/my-custom-role.
What properties can't be changed after creation?
The name, project, zone, role, and condition properties are immutable and require resource replacement if changed.

Using a different cloud?

Explore security guides for other cloud providers: