Configure GCP Cloud Run Service IAM Bindings

The gcp:cloudrunv2/serviceIamBinding:ServiceIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for Cloud Run v2 services. It grants a specific role to a list of members authoritatively, meaning it replaces any existing member list for that role. This guide focuses on two capabilities: authoritative role binding to multiple members and non-authoritative single-member grants.

IAM bindings reference existing Cloud Run services and require project and location identifiers. The examples are intentionally small. Combine them with your own service definitions and identity management strategy.

Grant a role to multiple members at once

When multiple users or service accounts need the same level of access, ServiceIamBinding grants a role to all specified members in a single resource.

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

const binding = new gcp.cloudrunv2.ServiceIamBinding("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.ServiceIamBinding("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.NewServiceIamBinding(ctx, "binding", &cloudrunv2.ServiceIamBindingArgs{
			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.ServiceIamBinding("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.ServiceIamBinding;
import com.pulumi.gcp.cloudrunv2.ServiceIamBindingArgs;
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 ServiceIamBinding("binding", ServiceIamBindingArgs.builder()
            .project(default_.project())
            .location(default_.location())
            .name(default_.name())
            .role("roles/viewer")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  binding:
    type: gcp:cloudrunv2:ServiceIamBinding
    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 that receive this role; ServiceIamBinding replaces any existing member list for this role on the service. The project, location, and name properties identify the Cloud Run service to bind permissions to.

Add a single member to a role incrementally

Teams managing access through multiple stacks or adding members without affecting existing grants use ServiceIamMember for non-authoritative updates.

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

const member = new gcp.cloudrunv2.ServiceIamMember("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.ServiceIamMember("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.NewServiceIamMember(ctx, "member", &cloudrunv2.ServiceIamMemberArgs{
			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.ServiceIamMember("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.ServiceIamMember;
import com.pulumi.gcp.cloudrunv2.ServiceIamMemberArgs;
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 ServiceIamMember("member", ServiceIamMemberArgs.builder()
            .project(default_.project())
            .location(default_.location())
            .name(default_.name())
            .role("roles/viewer")
            .member("user:jane@example.com")
            .build());

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

ServiceIamMember adds one member to a role without replacing existing members. The member property (singular) specifies a single identity, while ServiceIamBinding uses members (plural) for authoritative lists. This resource preserves other members already granted the same role, making it safe to use alongside other IAM resources that don’t conflict on the same role.

Beyond these examples

These snippets focus on specific IAM binding features: role-based access control and authoritative vs non-authoritative member grants. They’re intentionally minimal rather than full access control policies.

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

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

  • Conditional IAM bindings (condition property)
  • Full policy management (ServiceIamPolicy resource)
  • Custom role definitions
  • Federated identity and workload identity configuration

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

Let's configure GCP Cloud Run 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
Why are my IAM policies conflicting or fighting with each other?
ServiceIamPolicy cannot be used together with ServiceIamBinding or ServiceIamMember because they will conflict over the policy. Use either ServiceIamPolicy alone (authoritative for entire policy) or use ServiceIamBinding/ServiceIamMember together.
Can I use ServiceIamBinding and ServiceIamMember together?
Yes, but only if they grant privileges to different roles. Using both for the same role will cause conflicts.
Which IAM resource should I use for my Cloud Run service?
Use ServiceIamPolicy to replace the entire IAM policy authoritatively. Use ServiceIamBinding to manage all members for a specific role while preserving other roles. Use ServiceIamMember to add individual members non-authoritatively while preserving existing members.
Configuration & Identity Formats
What member identity formats are supported?
You can use: allUsers (anyone on internet), allAuthenticatedUsers (any Google account), user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner:projectid, projectEditor:projectid, projectViewer:projectid, or federated identities like principal://iam.googleapis.com/....
How do I grant public access to my Cloud Run service?
Add allUsers to the members array to grant access to anyone on the internet, with or without a Google account.
What format do custom roles need to use?
Custom roles must use the format [projects|organizations]/{parent-name}/roles/{role-name}.
Immutability & Limitations
What properties can't I change after creating a ServiceIamBinding?
The role, location, name, project, and condition properties are all immutable and cannot be changed after creation.
Can I use multiple ServiceIamBinding resources for the same role?
No, only one ServiceIamBinding can be used per role. If you need to manage individual members for a role, use ServiceIamMember instead.

Using a different cloud?

Explore security guides for other cloud providers: