Manage GCP Backend Service IAM Bindings

The gcp:compute/backendServiceIamBinding:BackendServiceIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for Compute Engine backend services, controlling which identities can access or manage the service. This guide focuses on three capabilities: granting roles to multiple members, adding individual members to roles, and time-based conditional access.

IAM bindings reference existing backend services and operate within GCP projects. The examples are intentionally small. Combine them with your own backend service infrastructure and identity management strategy.

Grant a role to multiple members at once

Teams managing backend service access often need to grant the same role to multiple users or service accounts simultaneously, ensuring consistent permissions across a group.

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

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

binding = gcp.compute.BackendServiceIamBinding("binding",
    project=default["project"],
    name=default["name"],
    role="roles/compute.admin",
    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.NewBackendServiceIamBinding(ctx, "binding", &compute.BackendServiceIamBindingArgs{
			Project: pulumi.Any(_default.Project),
			Name:    pulumi.Any(_default.Name),
			Role:    pulumi.String("roles/compute.admin"),
			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.BackendServiceIamBinding("binding", new()
    {
        Project = @default.Project,
        Name = @default.Name,
        Role = "roles/compute.admin",
        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.BackendServiceIamBinding;
import com.pulumi.gcp.compute.BackendServiceIamBindingArgs;
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 BackendServiceIamBinding("binding", BackendServiceIamBindingArgs.builder()
            .project(default_.project())
            .name(default_.name())
            .role("roles/compute.admin")
            .members("user:jane@example.com")
            .build());

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

The role property specifies which permissions to grant (e.g., roles/compute.admin). The members array lists all identities receiving this role; this resource is authoritative for the role, meaning it replaces any existing member list. The name property identifies the backend service, and project specifies the GCP project context.

Add time-based access with IAM Conditions

Organizations implementing temporary access or time-limited permissions use IAM Conditions to automatically expire grants without manual cleanup.

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

const binding = new gcp.compute.BackendServiceIamBinding("binding", {
    project: _default.project,
    name: _default.name,
    role: "roles/compute.admin",
    members: ["user:jane@example.com"],
    condition: {
        title: "expires_after_2019_12_31",
        description: "Expiring at midnight of 2019-12-31",
        expression: "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
    },
});
import pulumi
import pulumi_gcp as gcp

binding = gcp.compute.BackendServiceIamBinding("binding",
    project=default["project"],
    name=default["name"],
    role="roles/compute.admin",
    members=["user:jane@example.com"],
    condition={
        "title": "expires_after_2019_12_31",
        "description": "Expiring at midnight of 2019-12-31",
        "expression": "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
    })
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.NewBackendServiceIamBinding(ctx, "binding", &compute.BackendServiceIamBindingArgs{
			Project: pulumi.Any(_default.Project),
			Name:    pulumi.Any(_default.Name),
			Role:    pulumi.String("roles/compute.admin"),
			Members: pulumi.StringArray{
				pulumi.String("user:jane@example.com"),
			},
			Condition: &compute.BackendServiceIamBindingConditionArgs{
				Title:       pulumi.String("expires_after_2019_12_31"),
				Description: pulumi.String("Expiring at midnight of 2019-12-31"),
				Expression:  pulumi.String("request.time < timestamp(\"2020-01-01T00:00:00Z\")"),
			},
		})
		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.BackendServiceIamBinding("binding", new()
    {
        Project = @default.Project,
        Name = @default.Name,
        Role = "roles/compute.admin",
        Members = new[]
        {
            "user:jane@example.com",
        },
        Condition = new Gcp.Compute.Inputs.BackendServiceIamBindingConditionArgs
        {
            Title = "expires_after_2019_12_31",
            Description = "Expiring at midnight of 2019-12-31",
            Expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.BackendServiceIamBinding;
import com.pulumi.gcp.compute.BackendServiceIamBindingArgs;
import com.pulumi.gcp.compute.inputs.BackendServiceIamBindingConditionArgs;
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 BackendServiceIamBinding("binding", BackendServiceIamBindingArgs.builder()
            .project(default_.project())
            .name(default_.name())
            .role("roles/compute.admin")
            .members("user:jane@example.com")
            .condition(BackendServiceIamBindingConditionArgs.builder()
                .title("expires_after_2019_12_31")
                .description("Expiring at midnight of 2019-12-31")
                .expression("request.time < timestamp(\"2020-01-01T00:00:00Z\")")
                .build())
            .build());

    }
}
resources:
  binding:
    type: gcp:compute:BackendServiceIamBinding
    properties:
      project: ${default.project}
      name: ${default.name}
      role: roles/compute.admin
      members:
        - user:jane@example.com
      condition:
        title: expires_after_2019_12_31
        description: Expiring at midnight of 2019-12-31
        expression: request.time < timestamp("2020-01-01T00:00:00Z")

The condition block adds temporal or contextual constraints to the role binding. The expression property uses Common Expression Language (CEL) to define when access is valid; here, it expires at midnight on 2020-01-01. The title and description provide human-readable context for the condition. IAM Conditions have known limitations documented in the GCP IAM Conditions overview.

Add a single member to an existing role

When onboarding individual users or service accounts, teams add them one at a time to preserve existing role assignments without replacing the entire member list.

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

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

member = gcp.compute.BackendServiceIamMember("member",
    project=default["project"],
    name=default["name"],
    role="roles/compute.admin",
    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.NewBackendServiceIamMember(ctx, "member", &compute.BackendServiceIamMemberArgs{
			Project: pulumi.Any(_default.Project),
			Name:    pulumi.Any(_default.Name),
			Role:    pulumi.String("roles/compute.admin"),
			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.BackendServiceIamMember("member", new()
    {
        Project = @default.Project,
        Name = @default.Name,
        Role = "roles/compute.admin",
        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.BackendServiceIamMember;
import com.pulumi.gcp.compute.BackendServiceIamMemberArgs;
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 BackendServiceIamMember("member", BackendServiceIamMemberArgs.builder()
            .project(default_.project())
            .name(default_.name())
            .role("roles/compute.admin")
            .member("user:jane@example.com")
            .build());

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

The member property specifies a single identity to grant the role. Unlike BackendServiceIamBinding (which manages all members for a role), BackendServiceIamMember is non-authoritative: it adds one member without affecting others. This approach works well for incremental access grants but requires careful coordination to avoid conflicts when multiple resources manage the same role.

Beyond these examples

These snippets focus on specific IAM binding features: role binding for multiple members, single-member grants, and time-based conditional access. They’re intentionally minimal rather than full access control configurations.

The examples reference pre-existing infrastructure such as backend services and GCP projects. They focus on configuring IAM bindings rather than provisioning the underlying compute resources.

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

  • Full policy replacement (BackendServiceIamPolicy)
  • Policy data retrieval (data source)
  • Custom role format and organization-level roles
  • Federated identity and workload identity pool configuration

These omissions are intentional: the goal is to illustrate how each IAM binding feature is wired, not provide drop-in access control modules. See the BackendServiceIamBinding resource reference for all available configuration options.

Let's manage GCP Backend 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 resource should I use: Policy, Binding, or Member?

Choose based on your management style:

  • BackendServiceIamPolicy replaces the entire IAM policy (authoritative)
  • BackendServiceIamBinding manages all members for a specific role (authoritative per role)
  • BackendServiceIamMember adds individual members without affecting others (non-authoritative)
Can I use BackendServiceIamPolicy with BackendServiceIamBinding or BackendServiceIamMember?
No, BackendServiceIamPolicy cannot be used with BackendServiceIamBinding or BackendServiceIamMember because they will conflict over the policy configuration.
Can I use BackendServiceIamBinding and BackendServiceIamMember together?
Yes, but only if they manage different roles. Using both resources for the same role will cause conflicts.
IAM Configuration
What member identity formats are supported?

The members property accepts:

  • user:{email} for Google accounts
  • serviceAccount:{email} for service accounts
  • group:{email} for Google groups
  • domain:{domain} for G Suite domains
  • allUsers and allAuthenticatedUsers for public access
  • projectOwner:, projectEditor:, projectViewer: with project ID
  • Federated identities using principal:// format
How do I specify a custom IAM role?
Custom roles must use the format [projects|organizations]/{parent-name}/roles/{role-name}. For example: projects/my-project/roles/my-custom-role.
How do I add time-based or conditional access?
Use the condition property with title, description, and expression fields. For example, to expire access: expression: "request.time < timestamp(\"2020-01-01T00:00:00Z\")". Note that IAM Conditions have some known limitations.
Resource Properties & Constraints
What properties can't be changed after creation?
The name, project, role, and condition properties are immutable and require resource replacement if changed.

Using a different cloud?

Explore security guides for other cloud providers: