Manage GCP Cloud Run IAM Permissions

The gcp:cloudrun/iamMember:IamMember resource, part of the Pulumi GCP provider, grants IAM permissions on 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 lists, and complete policy replacement.

IAM resources reference existing Cloud Run services and use different authoritativeness levels. IamMember is non-authoritative (preserves other members), IamBinding is authoritative for one role (replaces all members for that role), and IamPolicy is fully authoritative (replaces the entire policy). IamPolicy cannot be used with IamBinding or IamMember, or they will conflict. 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 formats like “user:jane@example.com” or “serviceAccount:app@project.iam.gserviceaccount.com”. The role property defines what they can do. IamMember is non-authoritative: it adds this one member to the role while preserving all other IAM bindings on the service.

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 identity strings. IamBinding is authoritative for the specified role: it replaces all members for that role but preserves other roles on the service. If you later add another IamBinding for the same role, they will conflict.

Replace the entire IAM policy with a data source

Some deployments set the complete IAM policy from a centralized definition, replacing any existing permissions.

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 policyData property accepts a complete IAM policy document, typically from the getIAMPolicy data source. IamPolicy is fully authoritative: it overwrites all existing bindings on the service. This resource cannot be used alongside IamBinding or IamMember, or they will fight over the policy state.

Beyond these examples

These snippets focus on specific IAM management features: incremental member grants (IamMember), role-level member lists (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 IAM policy data sources (for IamPolicy examples). 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
  • Cross-project or cross-organization grants

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 but preserves other roles. gcp.cloudrun.IamMember is non-authoritative and adds a single member while preserving other members for that role.
Can I use IamPolicy with IamBinding or IamMember?
No, gcp.cloudrun.IamPolicy cannot be used with gcp.cloudrun.IamBinding or gcp.cloudrun.IamMember because they will conflict over the policy. Choose one approach: use IamPolicy for full control, or use IamBinding/IamMember for incremental changes.
Can I use IamBinding and IamMember together?
Yes, but only if they don’t grant privileges to the same role. If both resources target the same role, they will conflict.
Configuration & Identity Formats
What member identity formats are supported?
You can use allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner:{projectid}, projectEditor:{projectid}, projectViewer:{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}. For example, projects/my-project/roles/my-custom-role.
Immutability & Lifecycle
What properties can't be changed after creation?
All properties are immutable: location, member, project, role, service, and condition. Changing any of these requires recreating the resource.

Using a different cloud?

Explore security guides for other cloud providers: