Manage GCP Subnetwork IAM Bindings

The gcp:compute/subnetworkIAMBinding:SubnetworkIAMBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for VPC subnetworks, controlling which identities can use the subnetwork for compute resources. This guide focuses on three capabilities: authoritative role bindings with multiple members, time-based access with IAM Conditions, and non-authoritative single-member grants.

IAM bindings reference existing subnetworks by name, project, and region. The examples are intentionally small. Combine them with your own subnetwork infrastructure and identity management strategy.

Grant a role to multiple members at once

Teams managing VPC access often need to grant the same role to multiple users or service accounts simultaneously. SubnetworkIAMBinding provides authoritative control over who has a specific role.

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

const binding = new gcp.compute.SubnetworkIAMBinding("binding", {
    project: network_with_private_secondary_ip_ranges.project,
    region: network_with_private_secondary_ip_ranges.region,
    subnetwork: network_with_private_secondary_ip_ranges.name,
    role: "roles/compute.networkUser",
    members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp

binding = gcp.compute.SubnetworkIAMBinding("binding",
    project=network_with_private_secondary_ip_ranges["project"],
    region=network_with_private_secondary_ip_ranges["region"],
    subnetwork=network_with_private_secondary_ip_ranges["name"],
    role="roles/compute.networkUser",
    members=["user:jane@example.com"])
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewSubnetworkIAMBinding(ctx, "binding", &compute.SubnetworkIAMBindingArgs{
			Project:    pulumi.Any(network_with_private_secondary_ip_ranges.Project),
			Region:     pulumi.Any(network_with_private_secondary_ip_ranges.Region),
			Subnetwork: pulumi.Any(network_with_private_secondary_ip_ranges.Name),
			Role:       pulumi.String("roles/compute.networkUser"),
			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.Compute.SubnetworkIAMBinding("binding", new()
    {
        Project = network_with_private_secondary_ip_ranges.Project,
        Region = network_with_private_secondary_ip_ranges.Region,
        Subnetwork = network_with_private_secondary_ip_ranges.Name,
        Role = "roles/compute.networkUser",
        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.compute.SubnetworkIAMBinding;
import com.pulumi.gcp.compute.SubnetworkIAMBindingArgs;
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 SubnetworkIAMBinding("binding", SubnetworkIAMBindingArgs.builder()
            .project(network_with_private_secondary_ip_ranges.project())
            .region(network_with_private_secondary_ip_ranges.region())
            .subnetwork(network_with_private_secondary_ip_ranges.name())
            .role("roles/compute.networkUser")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  binding:
    type: gcp:compute:SubnetworkIAMBinding
    properties:
      project: ${["network-with-private-secondary-ip-ranges"].project}
      region: ${["network-with-private-secondary-ip-ranges"].region}
      subnetwork: ${["network-with-private-secondary-ip-ranges"].name}
      role: roles/compute.networkUser
      members:
        - user:jane@example.com

The role property specifies which permission set to grant (here, compute.networkUser allows attaching VMs to the subnetwork). The members array lists all identities that should have this role; any previous members for this role are replaced. The subnetwork, project, and region properties identify which subnetwork to configure.

Add time-based access with IAM Conditions

Temporary access grants expire automatically when you attach IAM Conditions to bindings, useful for contractor access or time-limited testing.

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

const binding = new gcp.compute.SubnetworkIAMBinding("binding", {
    project: network_with_private_secondary_ip_ranges.project,
    region: network_with_private_secondary_ip_ranges.region,
    subnetwork: network_with_private_secondary_ip_ranges.name,
    role: "roles/compute.networkUser",
    members: ["user:jane@example.com"],
    condition: {
        title: "expires_after_2019_12_31",
        description: "Expiring at midnight of 2019-12-31",
        expression: "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
    },
});
import pulumi
import pulumi_gcp as gcp

binding = gcp.compute.SubnetworkIAMBinding("binding",
    project=network_with_private_secondary_ip_ranges["project"],
    region=network_with_private_secondary_ip_ranges["region"],
    subnetwork=network_with_private_secondary_ip_ranges["name"],
    role="roles/compute.networkUser",
    members=["user:jane@example.com"],
    condition={
        "title": "expires_after_2019_12_31",
        "description": "Expiring at midnight of 2019-12-31",
        "expression": "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
    })
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewSubnetworkIAMBinding(ctx, "binding", &compute.SubnetworkIAMBindingArgs{
			Project:    pulumi.Any(network_with_private_secondary_ip_ranges.Project),
			Region:     pulumi.Any(network_with_private_secondary_ip_ranges.Region),
			Subnetwork: pulumi.Any(network_with_private_secondary_ip_ranges.Name),
			Role:       pulumi.String("roles/compute.networkUser"),
			Members: pulumi.StringArray{
				pulumi.String("user:jane@example.com"),
			},
			Condition: &compute.SubnetworkIAMBindingConditionArgs{
				Title:       pulumi.String("expires_after_2019_12_31"),
				Description: pulumi.String("Expiring at midnight of 2019-12-31"),
				Expression:  pulumi.String("request.time < timestamp(\"2020-01-01T00:00:00Z\")"),
			},
		})
		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.Compute.SubnetworkIAMBinding("binding", new()
    {
        Project = network_with_private_secondary_ip_ranges.Project,
        Region = network_with_private_secondary_ip_ranges.Region,
        Subnetwork = network_with_private_secondary_ip_ranges.Name,
        Role = "roles/compute.networkUser",
        Members = new[]
        {
            "user:jane@example.com",
        },
        Condition = new Gcp.Compute.Inputs.SubnetworkIAMBindingConditionArgs
        {
            Title = "expires_after_2019_12_31",
            Description = "Expiring at midnight of 2019-12-31",
            Expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.SubnetworkIAMBinding;
import com.pulumi.gcp.compute.SubnetworkIAMBindingArgs;
import com.pulumi.gcp.compute.inputs.SubnetworkIAMBindingConditionArgs;
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 SubnetworkIAMBinding("binding", SubnetworkIAMBindingArgs.builder()
            .project(network_with_private_secondary_ip_ranges.project())
            .region(network_with_private_secondary_ip_ranges.region())
            .subnetwork(network_with_private_secondary_ip_ranges.name())
            .role("roles/compute.networkUser")
            .members("user:jane@example.com")
            .condition(SubnetworkIAMBindingConditionArgs.builder()
                .title("expires_after_2019_12_31")
                .description("Expiring at midnight of 2019-12-31")
                .expression("request.time < timestamp(\"2020-01-01T00:00:00Z\")")
                .build())
            .build());

    }
}
resources:
  binding:
    type: gcp:compute:SubnetworkIAMBinding
    properties:
      project: ${["network-with-private-secondary-ip-ranges"].project}
      region: ${["network-with-private-secondary-ip-ranges"].region}
      subnetwork: ${["network-with-private-secondary-ip-ranges"].name}
      role: roles/compute.networkUser
      members:
        - user:jane@example.com
      condition:
        title: expires_after_2019_12_31
        description: Expiring at midnight of 2019-12-31
        expression: request.time < timestamp("2020-01-01T00:00:00Z")

The condition block adds temporal constraints to the binding. The expression property uses Common Expression Language (CEL) to define when access is valid; here, access expires at midnight on 2020-01-01. The title and description provide human-readable context for the condition.

Add a single member to an existing role

When you need to grant access to one additional user without affecting other members, SubnetworkIAMMember provides non-authoritative updates.

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

const member = new gcp.compute.SubnetworkIAMMember("member", {
    project: network_with_private_secondary_ip_ranges.project,
    region: network_with_private_secondary_ip_ranges.region,
    subnetwork: network_with_private_secondary_ip_ranges.name,
    role: "roles/compute.networkUser",
    member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp

member = gcp.compute.SubnetworkIAMMember("member",
    project=network_with_private_secondary_ip_ranges["project"],
    region=network_with_private_secondary_ip_ranges["region"],
    subnetwork=network_with_private_secondary_ip_ranges["name"],
    role="roles/compute.networkUser",
    member="user:jane@example.com")
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewSubnetworkIAMMember(ctx, "member", &compute.SubnetworkIAMMemberArgs{
			Project:    pulumi.Any(network_with_private_secondary_ip_ranges.Project),
			Region:     pulumi.Any(network_with_private_secondary_ip_ranges.Region),
			Subnetwork: pulumi.Any(network_with_private_secondary_ip_ranges.Name),
			Role:       pulumi.String("roles/compute.networkUser"),
			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.Compute.SubnetworkIAMMember("member", new()
    {
        Project = network_with_private_secondary_ip_ranges.Project,
        Region = network_with_private_secondary_ip_ranges.Region,
        Subnetwork = network_with_private_secondary_ip_ranges.Name,
        Role = "roles/compute.networkUser",
        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.compute.SubnetworkIAMMember;
import com.pulumi.gcp.compute.SubnetworkIAMMemberArgs;
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 SubnetworkIAMMember("member", SubnetworkIAMMemberArgs.builder()
            .project(network_with_private_secondary_ip_ranges.project())
            .region(network_with_private_secondary_ip_ranges.region())
            .subnetwork(network_with_private_secondary_ip_ranges.name())
            .role("roles/compute.networkUser")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  member:
    type: gcp:compute:SubnetworkIAMMember
    properties:
      project: ${["network-with-private-secondary-ip-ranges"].project}
      region: ${["network-with-private-secondary-ip-ranges"].region}
      subnetwork: ${["network-with-private-secondary-ip-ranges"].name}
      role: roles/compute.networkUser
      member: user:jane@example.com

The member property specifies a single identity to add (note the singular form, unlike members in SubnetworkIAMBinding). Multiple SubnetworkIAMMember resources can target the same role without conflict, each adding one identity. This approach preserves existing members rather than replacing them.

Beyond these examples

These snippets focus on specific subnetwork IAM features: authoritative role bindings, non-authoritative member grants, and time-based access with IAM Conditions. They’re intentionally minimal rather than full access control policies.

The examples reference pre-existing infrastructure such as VPC subnetworks (by name, project, and region). They focus on configuring IAM bindings rather than provisioning the underlying network resources.

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

  • Full policy replacement (SubnetworkIAMPolicy)
  • Custom role definitions and formatting
  • Federated identity and workload identity pool configuration
  • Combining multiple resource types (Policy vs Binding vs Member)

These omissions are intentional: the goal is to illustrate how each IAM binding approach is wired, not provide drop-in access control modules. See the Subnetwork IAM Binding resource reference for all available configuration options.

Let's manage GCP Subnetwork 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 Conflicts & Compatibility
Can I use SubnetworkIAMPolicy with SubnetworkIAMBinding or SubnetworkIAMMember?
No, gcp.compute.SubnetworkIAMPolicy cannot be used with gcp.compute.SubnetworkIAMBinding or gcp.compute.SubnetworkIAMMember as they will conflict over policy control. Choose one approach: use SubnetworkIAMPolicy for full policy management, or use SubnetworkIAMBinding/SubnetworkIAMMember for granular role management.
Can I use SubnetworkIAMBinding and SubnetworkIAMMember together?
Yes, but only if they don’t grant privileges to the same role. Each role must be managed by only one resource type to avoid conflicts.
IAM Conditions
Does this resource support IAM Conditions?
Yes, but IAM Conditions have known limitations. Review the limitations documentation before using conditions in production.
How do I add time-based access conditions to a binding?
Use the condition property with title, description, and expression fields. For example, to expire access at midnight on 2020-01-01: expression: "request.time < timestamp(\"2020-01-01T00:00:00Z\")".
Configuration & Identity Management
What member identity formats are supported?

The members property supports multiple identity formats:

  • user:{emailid} for Google accounts
  • serviceAccount:{emailid} for service accounts
  • group:{emailid} for Google groups
  • domain:{domain} for G Suite domains
  • allUsers and allAuthenticatedUsers for public access
  • projectOwner:projectid, projectEditor:projectid, projectViewer:projectid for project roles
  • Federated identities using principal:// format
What's the correct format for custom 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.
What's the difference between SubnetworkIAMPolicy, SubnetworkIAMBinding, and SubnetworkIAMMember?
  • SubnetworkIAMPolicy: Authoritative for the entire policy; replaces all existing bindings
  • SubnetworkIAMBinding: Authoritative for a specific role; manages all members for that role
  • SubnetworkIAMMember: Non-authoritative; adds a single member to a role without affecting other members
Lifecycle & Import
What properties can't I change after creating a binding?
The following properties are immutable: role, condition, project, region, and subnetwork. Changing any of these requires recreating the resource.
How do I import an existing IAM binding with a custom role?
Use the full custom role name in the import command: pulumi import gcp:compute/subnetworkIAMBinding:SubnetworkIAMBinding editor "projects/{{project}}/regions/{{region}}/subnetworks/{{subnetwork}} [projects/my-project|organizations/my-org]/roles/my-custom-role".

Using a different cloud?

Explore security guides for other cloud providers: