The gcp:cloudrunv2/workerPoolIamBinding:WorkerPoolIamBinding resource, part of the Pulumi GCP provider, manages IAM access control for Cloud Run v2 worker pools by granting roles to members. This guide focuses on three capabilities: authoritative role binding to multiple members, non-authoritative single member grants, and full policy replacement with data sources.
These IAM resources reference existing worker pools and require project and location identifiers. The examples are intentionally small. Combine them with your own worker pool infrastructure and identity management.
Grant a role to multiple members at once
When multiple users or service accounts need the same access level, WorkerPoolIamBinding grants a role to all specified members in one resource.
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 role property specifies which permission set to grant (e.g., “roles/viewer”). The members array lists all identities receiving that role. This resource is authoritative for the specified role: it replaces any existing members for that role but preserves other roles on the worker pool.
Add a single member to a role incrementally
Teams managing access across multiple stacks or adding members without affecting existing grants use WorkerPoolIamMember for non-authoritative updates.
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 member property specifies a single identity to grant access. Unlike WorkerPoolIamBinding, this resource adds the member without replacing others who already have the role. You can use multiple WorkerPoolIamMember resources for the same role without conflicts.
Replace the entire IAM policy with a data source
Organizations with centralized IAM policies use WorkerPoolIamPolicy to define the complete access control list, replacing any existing policy.
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 policyData property accepts output from the getIAMPolicy data source, which defines all roles and members. This resource is fully authoritative: it replaces the entire IAM policy. It cannot be used alongside WorkerPoolIamBinding or WorkerPoolIamMember, as they would conflict over policy ownership.
Beyond these examples
These snippets focus on specific IAM management features: role-based access control, incremental vs authoritative IAM updates, and policy data source integration. They’re intentionally minimal rather than full access control systems.
The examples reference pre-existing infrastructure such as Cloud Run v2 worker pools and GCP projects with configured locations. They focus on configuring IAM bindings rather than provisioning the underlying worker pool resources.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Custom role definitions and formatting
- Service account creation and management
- Federated identity configuration
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 FREEFrequently Asked Questions
Resource Selection & Conflicts
WorkerPoolIamPolicy is fully authoritative and replaces the entire IAM policy. WorkerPoolIamBinding is authoritative for a specific role, managing all members for that role while preserving other roles. WorkerPoolIamMember is non-authoritative, adding a single member to a role without affecting other members.WorkerPoolIamPolicy with WorkerPoolIamBinding or WorkerPoolIamMember, as they will conflict. However, you can use WorkerPoolIamBinding with WorkerPoolIamMember only if they manage different roles.WorkerPoolIamPolicy with WorkerPoolIamBinding or WorkerPoolIamMember causes them to fight over the policy. Similarly, using WorkerPoolIamBinding and WorkerPoolIamMember for the same role creates conflicts.IAM Configuration
allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner:{projectid}, projectEditor:{projectid}, projectViewer:{projectid}, or federated identities like principal://iam.googleapis.com/....WorkerPoolIamBinding with the members array containing multiple identities, such as ["user:jane@example.com", "user:john@example.com"].WorkerPoolIamMember with the member property set to a single identity like user:jane@example.com. This is non-authoritative and preserves existing members.Custom Roles
[projects|organizations]/{parent-name}/roles/{role-name}, such as projects/my-project/roles/my-custom-role.