Manage GCP Cloud Run Worker Pool IAM Bindings

The gcp:cloudrunv2/workerPoolIamBinding:WorkerPoolIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for Cloud Run worker pools, controlling which identities can access the worker pool. This guide focuses on three capabilities: granting roles to multiple members, adding individual members non-authoritatively, and replacing entire IAM policies.

These resources reference existing worker pools and require project and location context. The examples are intentionally small. Combine them with your own worker pool infrastructure and identity management strategy.

Grant a role to multiple members at once

When managing access for development teams, you often need to assign the same role to multiple users or service accounts simultaneously.

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

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

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

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudrunv2.NewWorkerPoolIamBinding(ctx, "binding", &cloudrunv2.WorkerPoolIamBindingArgs{
			Project:  pulumi.Any(_default.Project),
			Location: pulumi.Any(_default.Location),
			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.CloudRunV2.WorkerPoolIamBinding("binding", new()
    {
        Project = @default.Project,
        Location = @default.Location,
        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.cloudrunv2.WorkerPoolIamBinding;
import com.pulumi.gcp.cloudrunv2.WorkerPoolIamBindingArgs;
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 WorkerPoolIamBinding("binding", WorkerPoolIamBindingArgs.builder()
            .project(default_.project())
            .location(default_.location())
            .name(default_.name())
            .role("roles/viewer")
            .members("user:jane@example.com")
            .build());

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

The WorkerPoolIamBinding resource is authoritative for the specified role. The members array lists all identities that should have this role; any existing members not in this list will be removed. The role property accepts predefined roles like “roles/viewer” or custom roles in the format “projects/{project}/roles/{role-name}”.

Add a single member to an existing role

When onboarding individual users, you want to grant access without affecting others who already have the same role.

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

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

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

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudrunv2.NewWorkerPoolIamMember(ctx, "member", &cloudrunv2.WorkerPoolIamMemberArgs{
			Project:  pulumi.Any(_default.Project),
			Location: pulumi.Any(_default.Location),
			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.CloudRunV2.WorkerPoolIamMember("member", new()
    {
        Project = @default.Project,
        Location = @default.Location,
        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.cloudrunv2.WorkerPoolIamMember;
import com.pulumi.gcp.cloudrunv2.WorkerPoolIamMemberArgs;
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 WorkerPoolIamMember("member", WorkerPoolIamMemberArgs.builder()
            .project(default_.project())
            .location(default_.location())
            .name(default_.name())
            .role("roles/viewer")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  member:
    type: gcp:cloudrunv2:WorkerPoolIamMember
    properties:
      project: ${default.project}
      location: ${default.location}
      name: ${default.name}
      role: roles/viewer
      member: user:jane@example.com

The WorkerPoolIamMember resource is non-authoritative. It adds one identity to a role without removing other members. Use this when you need to grant access incrementally, such as adding service accounts as they’re created. Unlike WorkerPoolIamBinding, multiple WorkerPoolIamMember resources can target the same role without conflict.

Replace the entire IAM policy with a new definition

Some workflows require complete control over the IAM policy, replacing all existing bindings with a new set.

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.cloudrunv2.WorkerPoolIamPolicy("policy", {
    project: _default.project,
    location: _default.location,
    name: _default.name,
    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.cloudrunv2.WorkerPoolIamPolicy("policy",
    project=default["project"],
    location=default["location"],
    name=default["name"],
    policy_data=admin.policy_data)
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/cloudrunv2"
	"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 = cloudrunv2.NewWorkerPoolIamPolicy(ctx, "policy", &cloudrunv2.WorkerPoolIamPolicyArgs{
			Project:    pulumi.Any(_default.Project),
			Location:   pulumi.Any(_default.Location),
			Name:       pulumi.Any(_default.Name),
			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.CloudRunV2.WorkerPoolIamPolicy("policy", new()
    {
        Project = @default.Project,
        Location = @default.Location,
        Name = @default.Name,
        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.cloudrunv2.WorkerPoolIamPolicy;
import com.pulumi.gcp.cloudrunv2.WorkerPoolIamPolicyArgs;
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 WorkerPoolIamPolicy("policy", WorkerPoolIamPolicyArgs.builder()
            .project(default_.project())
            .location(default_.location())
            .name(default_.name())
            .policyData(admin.policyData())
            .build());

    }
}
resources:
  policy:
    type: gcp:cloudrunv2:WorkerPoolIamPolicy
    properties:
      project: ${default.project}
      location: ${default.location}
      name: ${default.name}
      policyData: ${admin.policyData}
variables:
  admin:
    fn::invoke:
      function: gcp:organizations:getIAMPolicy
      arguments:
        bindings:
          - role: roles/viewer
            members:
              - user:jane@example.com

The WorkerPoolIamPolicy resource is fully authoritative. It replaces the entire IAM policy with the bindings defined in policyData. The getIAMPolicy data source constructs the policy document from a list of role-to-members mappings. This approach cannot be used alongside WorkerPoolIamBinding or WorkerPoolIamMember resources; they will conflict over policy ownership.

Beyond these examples

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

The examples reference pre-existing infrastructure such as Cloud Run worker pools and a GCP project with configured location. They focus on configuring IAM bindings rather than provisioning the worker pools themselves.

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

  • Conditional IAM bindings (condition property)
  • Custom role definitions
  • Federated identity configuration details
  • 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 WorkerPoolIamBinding resource reference for all available configuration options.

Let's manage GCP Cloud Run Worker Pool 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
Can I use WorkerPoolIamPolicy together with WorkerPoolIamBinding or WorkerPoolIamMember?
No, WorkerPoolIamPolicy cannot be used with WorkerPoolIamBinding or WorkerPoolIamMember because they will conflict over the policy configuration.
Can I use WorkerPoolIamBinding and WorkerPoolIamMember together?
Yes, but only if they grant different roles. Using both for the same role causes conflicts.
What's the difference between WorkerPoolIamPolicy, WorkerPoolIamBinding, and WorkerPoolIamMember?
WorkerPoolIamPolicy is authoritative and replaces the entire IAM policy. WorkerPoolIamBinding is authoritative for a specific role but preserves other roles. WorkerPoolIamMember is non-authoritative and preserves other members for the same role.
IAM Configuration
What member identity formats are supported?
You can use allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner/Editor/Viewer:{projectid}, and federated identities (e.g., principal://iam.googleapis.com/...).
How do I specify a custom IAM role?
Custom roles must use the format [projects|organizations]/{parent-name}/roles/{role-name} (e.g., projects/my-project/roles/my-custom-role).
Can I change the role, location, or name after creation?
No, the role, location, name, and project properties are immutable and cannot be changed after creation.
Common Tasks
How do I grant a role to multiple users at once?
Use WorkerPoolIamBinding with a members array containing multiple identities (e.g., ["user:jane@example.com", "user:john@example.com"]).
How do I grant a role to a single user without affecting other members?
Use WorkerPoolIamMember with a single member identity. This preserves existing members for the role.
Which resource should I use to completely replace an IAM policy?
Use WorkerPoolIamPolicy with policyData from gcp.organizations.getIAMPolicy. This replaces the entire policy authoritatively.

Using a different cloud?

Explore security guides for other cloud providers: