Manage GCP Cloud Run IAM Permissions

The gcp:cloudrun/iamMember:IamMember resource, part of the Pulumi GCP provider, grants IAM permissions to Cloud Run services by adding individual members to roles without affecting other permissions. This guide focuses on three capabilities: non-authoritative single-member grants, authoritative role-level member management, and complete policy replacement.

Cloud Run IAM resources reference existing services and require careful coordination. IamPolicy cannot be used with IamBinding or IamMember on the same service, as they conflict over policy ownership. IamBinding and IamMember can coexist only if they manage different roles. The examples are intentionally small. Choose the resource type that matches your permission management strategy.

Grant a role to a single member

Most services need to grant specific permissions to individual users or service accounts without affecting existing permissions.

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

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

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

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

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

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

The member property specifies who receives the permission using GCP’s identity format (user:, serviceAccount:, group:, domain:, allUsers, or allAuthenticatedUsers). The role property defines what they can do. IamMember is non-authoritative: it adds this one member to this one role while preserving all other IAM bindings on the service. Use this when you need to grant permissions incrementally without managing the complete member list.

Grant a role to multiple members at once

When multiple users or service accounts need the same role, IamBinding manages the complete member list for that role.

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

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

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

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

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

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

The members property takes an array of identities in the same format as IamMember’s member property. IamBinding is authoritative for the specified role: it replaces the member list for that role but preserves other roles on the service. If you later add another IamMember for the same role, they will conflict. Use IamBinding when you want to define the complete set of members for a role in one place.

Replace the entire IAM policy with a data source

Organizations with centralized IAM policies can define bindings in a data source and apply them authoritatively.

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

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/cloudrun"
	"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 = cloudrun.NewIamPolicy(ctx, "policy", &cloudrun.IamPolicyArgs{
			Location:   pulumi.Any(_default.Location),
			Project:    pulumi.Any(_default.Project),
			Service:    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.CloudRun.IamPolicy("policy", new()
    {
        Location = @default.Location,
        Project = @default.Project,
        Service = @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.cloudrun.IamPolicy;
import com.pulumi.gcp.cloudrun.IamPolicyArgs;
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 IamPolicy("policy", IamPolicyArgs.builder()
            .location(default_.location())
            .project(default_.project())
            .service(default_.name())
            .policyData(admin.policyData())
            .build());

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

The getIAMPolicy data source constructs a complete policy document with multiple role bindings. The policyData property applies this policy to the service, replacing any existing policy. IamPolicy is fully authoritative: it removes any bindings not defined in the policy data. This approach cannot coexist with IamBinding or IamMember on the same service. Use IamPolicy when you need complete control over all permissions and want to prevent drift from a centralized definition.

Beyond these examples

These snippets focus on specific IAM management features: incremental member grants (IamMember), role-level member management (IamBinding), and complete policy replacement (IamPolicy). They’re intentionally minimal rather than full access control configurations.

The examples reference pre-existing infrastructure such as Cloud Run services and GCP project and location configuration. They focus on granting permissions rather than provisioning the services themselves.

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

  • Conditional IAM bindings (condition property)
  • Custom role definitions
  • Service account creation and management
  • Workload identity federation setup

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 Cloud Run IamMember resource reference for all available configuration options.

Let's manage GCP Cloud Run IAM Permissions

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 IamPolicy, IamBinding, and IamMember?
gcp.cloudrun.IamPolicy is authoritative and replaces the entire IAM policy. gcp.cloudrun.IamBinding is authoritative for a specific role, replacing all members for that role while preserving other roles. gcp.cloudrun.IamMember is non-authoritative and adds a single member to a role without affecting other members.
Can I use IamPolicy with IamBinding or IamMember?
No, gcp.cloudrun.IamPolicy cannot be used together with gcp.cloudrun.IamBinding or gcp.cloudrun.IamMember because they will conflict over the policy configuration.
Can I use IamBinding and IamMember together?
Yes, but only if they don’t grant privileges to the same role. If both resources manage the same role, they will conflict.
Identity & Member Configuration
What member identity formats are supported?
Supported formats include allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner:{projectid}, projectEditor:{projectid}, projectViewer:{projectid}, and federated identities like principal://iam.googleapis.com/....
How do I grant access to a single user?
Use gcp.cloudrun.IamMember with member set to the user identity (e.g., user:jane@example.com) and specify the role.
How do I grant access to multiple users for the same role?
Use gcp.cloudrun.IamBinding with the members property containing a list of identities and specify the role.
Roles & Custom Permissions
How do I specify a custom role?
Custom roles must use the format [projects|organizations]/{parent-name}/roles/{role-name}, for example projects/my-project/roles/my-custom-role.
Resource Management
Can I modify IAM bindings after creation?
No, all key properties (location, member, project, role, service) are immutable. To change these values, you must recreate the resource.
What import formats are supported?
For IamMember, use space-delimited format: "projects/{{project}}/locations/{{location}}/services/{{service}} roles/viewer user:jane@example.com". The resource identifier can also be shortened to {{location}}/{{service}} or just {{service}} if values are available from the provider configuration.

Using a different cloud?

Explore security guides for other cloud providers: