Manage GCP Cloud Build Connection IAM Bindings

The gcp:cloudbuildv2/connectionIAMBinding:ConnectionIAMBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for Cloud Build v2 connections. It grants a specific role to a list of members while preserving other roles on the connection. This guide focuses on two capabilities: granting roles to multiple members and adding individual members to roles.

IAM bindings reference existing Cloud Build v2 connections and require valid member identities. The examples are intentionally small. Combine them with your own connection resources and identity management.

Grant a role to multiple members at once

Teams managing connections often need to grant the same role to multiple users or service accounts simultaneously, such as giving a team read access.

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

const binding = new gcp.cloudbuildv2.ConnectionIAMBinding("binding", {
    project: my_connection.project,
    location: my_connection.location,
    name: my_connection.name,
    role: "roles/cloudbuild.connectionViewer",
    members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp

binding = gcp.cloudbuildv2.ConnectionIAMBinding("binding",
    project=my_connection["project"],
    location=my_connection["location"],
    name=my_connection["name"],
    role="roles/cloudbuild.connectionViewer",
    members=["user:jane@example.com"])
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudbuildv2.NewConnectionIAMBinding(ctx, "binding", &cloudbuildv2.ConnectionIAMBindingArgs{
			Project:  pulumi.Any(my_connection.Project),
			Location: pulumi.Any(my_connection.Location),
			Name:     pulumi.Any(my_connection.Name),
			Role:     pulumi.String("roles/cloudbuild.connectionViewer"),
			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.CloudBuildV2.ConnectionIAMBinding("binding", new()
    {
        Project = my_connection.Project,
        Location = my_connection.Location,
        Name = my_connection.Name,
        Role = "roles/cloudbuild.connectionViewer",
        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.cloudbuildv2.ConnectionIAMBinding;
import com.pulumi.gcp.cloudbuildv2.ConnectionIAMBindingArgs;
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 ConnectionIAMBinding("binding", ConnectionIAMBindingArgs.builder()
            .project(my_connection.project())
            .location(my_connection.location())
            .name(my_connection.name())
            .role("roles/cloudbuild.connectionViewer")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  binding:
    type: gcp:cloudbuildv2:ConnectionIAMBinding
    properties:
      project: ${["my-connection"].project}
      location: ${["my-connection"].location}
      name: ${["my-connection"].name}
      role: roles/cloudbuild.connectionViewer
      members:
        - user:jane@example.com

The role property specifies which permission to grant (here, connectionViewer for read access). The members array lists all identities that receive this role. This resource is authoritative for the role: it replaces any existing members for connectionViewer but leaves other roles untouched. The project, location, and name properties identify which connection to modify.

Add a single member to a role incrementally

When onboarding individual users or service accounts, you can add them one at a time without affecting existing role members.

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

const member = new gcp.cloudbuildv2.ConnectionIAMMember("member", {
    project: my_connection.project,
    location: my_connection.location,
    name: my_connection.name,
    role: "roles/cloudbuild.connectionViewer",
    member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp

member = gcp.cloudbuildv2.ConnectionIAMMember("member",
    project=my_connection["project"],
    location=my_connection["location"],
    name=my_connection["name"],
    role="roles/cloudbuild.connectionViewer",
    member="user:jane@example.com")
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudbuildv2.NewConnectionIAMMember(ctx, "member", &cloudbuildv2.ConnectionIAMMemberArgs{
			Project:  pulumi.Any(my_connection.Project),
			Location: pulumi.Any(my_connection.Location),
			Name:     pulumi.Any(my_connection.Name),
			Role:     pulumi.String("roles/cloudbuild.connectionViewer"),
			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.CloudBuildV2.ConnectionIAMMember("member", new()
    {
        Project = my_connection.Project,
        Location = my_connection.Location,
        Name = my_connection.Name,
        Role = "roles/cloudbuild.connectionViewer",
        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.cloudbuildv2.ConnectionIAMMember;
import com.pulumi.gcp.cloudbuildv2.ConnectionIAMMemberArgs;
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 ConnectionIAMMember("member", ConnectionIAMMemberArgs.builder()
            .project(my_connection.project())
            .location(my_connection.location())
            .name(my_connection.name())
            .role("roles/cloudbuild.connectionViewer")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  member:
    type: gcp:cloudbuildv2:ConnectionIAMMember
    properties:
      project: ${["my-connection"].project}
      location: ${["my-connection"].location}
      name: ${["my-connection"].name}
      role: roles/cloudbuild.connectionViewer
      member: user:jane@example.com

The member property (singular) specifies one identity to add. Unlike ConnectionIAMBinding, this resource is non-authoritative: it adds the member to the role without removing others. Use this when you need to grant access incrementally, such as onboarding new team members without redefining the entire member list.

Beyond these examples

These snippets focus on specific IAM binding features: role-based access control and bulk member assignment vs incremental addition. They’re intentionally minimal rather than full access control configurations.

The examples reference pre-existing infrastructure such as Cloud Build v2 connections. They focus on configuring IAM bindings rather than provisioning connections or managing identity providers.

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

  • Conditional IAM bindings (condition property)
  • Full policy replacement (ConnectionIAMPolicy)
  • 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 ConnectionIAMBinding resource reference for all available configuration options.

Let's manage GCP Cloud Build Connection 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 am I getting IAM policy conflicts between my Connection IAM resources?
ConnectionIAMPolicy cannot be used with ConnectionIAMBinding or ConnectionIAMMember because they fight over policy control. Use ConnectionIAMPolicy alone for full policy management, or use ConnectionIAMBinding and ConnectionIAMMember together (but never mix Policy with the others).
Which Connection IAM resource should I use?

Choose based on your needs:

  1. ConnectionIAMPolicy - Authoritative, replaces the entire IAM policy
  2. ConnectionIAMBinding - Authoritative for a specific role, preserves other roles
  3. ConnectionIAMMember - Non-authoritative, adds a single member while preserving others
Can I use ConnectionIAMBinding and ConnectionIAMMember together?
Yes, but only if they grant different roles. Using both for the same role causes conflicts.
Configuration & Usage
How do I specify a custom IAM role?
Custom roles must use the format [projects|organizations]/{parent-name}/roles/{role-name}.
What member identity formats are supported?

Supported formats include:

  • allUsers and allAuthenticatedUsers (special identifiers)
  • user:{email}, serviceAccount:{email}, group:{email} (Google identities)
  • domain:{domain} (G Suite domains)
  • projectOwner:projectid, projectEditor:projectid, projectViewer:projectid (project roles)
  • Federated identities (workload/workforce identity pools)

Using a different cloud?

Explore security guides for other cloud providers: