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 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 non-authoritatively.

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

Grant a role to multiple members

Teams managing Cloud Run services often need to grant the same role to multiple users, service accounts, or groups at once.

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

ServiceIamBinding is authoritative for the specified role: it replaces all members for that role with the list you provide. The members array accepts various identity formats including user emails, service accounts, groups, and special identifiers like allUsers or allAuthenticatedUsers. The role property specifies which permission set to grant; project, location, and name identify the target Cloud Run service.

Add a single member to a role

When you need to grant access to one additional user without affecting existing members, ServiceIamMember adds a single identity non-authoritatively.

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

Unlike ServiceIamBinding, ServiceIamMember preserves other members already granted the role. The member property (singular) specifies one identity to add. This approach works well when multiple teams manage access independently, as each ServiceIamMember resource only controls its own identity without overwriting others.

Beyond these examples

These snippets focus on specific IAM binding features: role-based access control and member management (binding vs individual). 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)
  • Policy-level management (ServiceIamPolicy resource)
  • Custom role definitions
  • Federated 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 ServiceIamBinding 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
What's the difference between ServiceIamPolicy, ServiceIamBinding, and ServiceIamMember?
ServiceIamPolicy is authoritative and replaces the entire IAM policy. ServiceIamBinding is authoritative for a specific role, preserving other roles. ServiceIamMember is non-authoritative, adding individual members without affecting other members for the same role.
Can I use ServiceIamPolicy with ServiceIamBinding or ServiceIamMember?
No, ServiceIamPolicy cannot be used with ServiceIamBinding or ServiceIamMember because they will conflict over the policy configuration.
Can I use ServiceIamBinding and ServiceIamMember together?
Yes, but only if they don’t grant privileges to the same role. Using both for the same role will cause conflicts.
IAM Configuration
What member identity formats are supported?
Supported formats include allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner/Editor/Viewer:{projectid}, and federated identities like principal://iam.googleapis.com/....
Can I bind multiple roles with a single ServiceIamBinding?
No, only one ServiceIamBinding can be used per role. Each role requires a separate binding resource.
What properties can't be changed after creation?
The location, name, project, role, and condition properties are immutable and cannot be changed after the resource is created.
Custom Roles & Advanced Usage
How do I use custom IAM roles?
Custom roles must use the format [projects|organizations]/{parent-name}/roles/{role-name}. For example, projects/my-project/roles/my-custom-role or organizations/my-org/roles/my-custom-role.
How do I import an existing IAM binding?
Use the format pulumi import gcp:cloudrunv2/serviceIamBinding:ServiceIamBinding editor "projects/{{project}}/locations/{{location}}/services/{{service}} roles/viewer" with space-delimited resource identifier and role.
What happens if I don't specify location or project?
If not specified, location and project are parsed from the parent resource identifier. If still unavailable, they’re taken from the provider configuration.

Using a different cloud?

Explore security guides for other cloud providers: