Configure GCP Compute Image IAM Bindings

The gcp:compute/imageIamBinding:ImageIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for Compute Engine images. It grants a specific role to a list of members authoritatively, meaning it controls all members for that role while preserving other roles on the image. This guide focuses on three capabilities: authoritative role binding for multiple members, time-based access with IAM Conditions, and non-authoritative member addition.

ImageIamBinding is one of three IAM resources for Compute Engine images. ImageIamPolicy replaces the entire policy (use carefully), ImageIamBinding controls all members for one role (this resource), and ImageIamMember adds individual members without affecting others. The examples are intentionally small. Combine them with your own image resources and access requirements.

Grant a role to multiple members at once

When managing shared compute images, you often need to grant the same role to multiple users or service accounts simultaneously.

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

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

binding = gcp.compute.ImageIamBinding("binding",
    project=example["project"],
    image=example["name"],
    role="roles/compute.imageUser",
    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.NewImageIamBinding(ctx, "binding", &compute.ImageIamBindingArgs{
			Project: pulumi.Any(example.Project),
			Image:   pulumi.Any(example.Name),
			Role:    pulumi.String("roles/compute.imageUser"),
			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.ImageIamBinding("binding", new()
    {
        Project = example.Project,
        Image = example.Name,
        Role = "roles/compute.imageUser",
        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.ImageIamBinding;
import com.pulumi.gcp.compute.ImageIamBindingArgs;
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 ImageIamBinding("binding", ImageIamBindingArgs.builder()
            .project(example.project())
            .image(example.name())
            .role("roles/compute.imageUser")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  binding:
    type: gcp:compute:ImageIamBinding
    properties:
      project: ${example.project}
      image: ${example.name}
      role: roles/compute.imageUser
      members:
        - user:jane@example.com

The members property lists all identities that receive the specified role. This binding is authoritative for the role, meaning it replaces any existing members for roles/compute.imageUser. The image property identifies which Compute Engine image receives the binding.

Add time-based access with IAM Conditions

Organizations implementing temporary access can attach conditions to bindings, automatically expiring permissions at a specified time.

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

const binding = new gcp.compute.ImageIamBinding("binding", {
    project: example.project,
    image: example.name,
    role: "roles/compute.imageUser",
    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.ImageIamBinding("binding",
    project=example["project"],
    image=example["name"],
    role="roles/compute.imageUser",
    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.NewImageIamBinding(ctx, "binding", &compute.ImageIamBindingArgs{
			Project: pulumi.Any(example.Project),
			Image:   pulumi.Any(example.Name),
			Role:    pulumi.String("roles/compute.imageUser"),
			Members: pulumi.StringArray{
				pulumi.String("user:jane@example.com"),
			},
			Condition: &compute.ImageIamBindingConditionArgs{
				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.ImageIamBinding("binding", new()
    {
        Project = example.Project,
        Image = example.Name,
        Role = "roles/compute.imageUser",
        Members = new[]
        {
            "user:jane@example.com",
        },
        Condition = new Gcp.Compute.Inputs.ImageIamBindingConditionArgs
        {
            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.ImageIamBinding;
import com.pulumi.gcp.compute.ImageIamBindingArgs;
import com.pulumi.gcp.compute.inputs.ImageIamBindingConditionArgs;
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 ImageIamBinding("binding", ImageIamBindingArgs.builder()
            .project(example.project())
            .image(example.name())
            .role("roles/compute.imageUser")
            .members("user:jane@example.com")
            .condition(ImageIamBindingConditionArgs.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:ImageIamBinding
    properties:
      project: ${example.project}
      image: ${example.name}
      role: roles/compute.imageUser
      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 or attribute-based constraints to the binding. The expression uses Common Expression Language (CEL) to define when access is valid. Here, the binding expires at midnight on 2020-01-01. The title and description provide human-readable context for auditing.

Add a single member to an existing role

When you need to grant access to one additional user without affecting other members, use ImageIamMember for non-authoritative updates.

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

const member = new gcp.compute.ImageIamMember("member", {
    project: example.project,
    image: example.name,
    role: "roles/compute.imageUser",
    member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp

member = gcp.compute.ImageIamMember("member",
    project=example["project"],
    image=example["name"],
    role="roles/compute.imageUser",
    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.NewImageIamMember(ctx, "member", &compute.ImageIamMemberArgs{
			Project: pulumi.Any(example.Project),
			Image:   pulumi.Any(example.Name),
			Role:    pulumi.String("roles/compute.imageUser"),
			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.ImageIamMember("member", new()
    {
        Project = example.Project,
        Image = example.Name,
        Role = "roles/compute.imageUser",
        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.ImageIamMember;
import com.pulumi.gcp.compute.ImageIamMemberArgs;
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 ImageIamMember("member", ImageIamMemberArgs.builder()
            .project(example.project())
            .image(example.name())
            .role("roles/compute.imageUser")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  member:
    type: gcp:compute:ImageIamMember
    properties:
      project: ${example.project}
      image: ${example.name}
      role: roles/compute.imageUser
      member: user:jane@example.com

The member property (singular) adds one identity to the role without replacing existing members. Unlike ImageIamBinding, this resource is non-authoritative: multiple ImageIamMember resources can target the same role, each adding one member. This approach works well for incremental access grants.

Beyond these examples

These snippets focus on specific IAM binding features: role-based access control, time-based IAM Conditions, and authoritative vs non-authoritative binding. They’re intentionally minimal rather than full access control configurations.

The examples reference pre-existing infrastructure such as Compute Engine images and GCP projects. They focus on configuring IAM bindings rather than provisioning the images themselves.

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

  • Full IAM policy replacement (ImageIamPolicy)
  • Custom role definitions and formatting
  • Federated identity configuration
  • Condition limitations and troubleshooting

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

Let's configure GCP Compute Image 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 ImageIamPolicy, ImageIamBinding, and ImageIamMember?
ImageIamPolicy is fully authoritative and replaces the entire IAM policy. ImageIamBinding is authoritative for a specific role but preserves other roles. ImageIamMember is non-authoritative and adds individual members without affecting other members for that role.
Can I use these IAM resources together?
ImageIamPolicy cannot be used with ImageIamBinding or ImageIamMember as they will conflict. ImageIamBinding and ImageIamMember can be used together only if they manage different roles.
Configuration & Member Identities
What member identity formats are supported?
You can use allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner/Editor/Viewer:{projectid}, and federated identities like principal://iam.googleapis.com/....
How do I specify custom roles?
Custom roles must use the format [projects|organizations]/{parent-name}/roles/{role-name}, for example projects/my-project/roles/my-custom-role.
IAM Conditions
How do I add time-based or conditional access?
Use the condition property with title, description, and expression fields. For example, set expression to request.time < timestamp("2020-01-01T00:00:00Z") to expire access at a specific time.
Are there limitations with IAM Conditions?
Yes, IAM Conditions have known limitations. If you experience issues, review the GCP IAM Conditions limitations documentation.
Immutability & Updates
What properties can't I change after creation?
The image, role, project, and condition properties are immutable. Changing any of these requires recreating the resource.
Can I update the list of members?
Yes, the members property is the only mutable field. You can add or remove members without recreating the binding.

Using a different cloud?

Explore security guides for other cloud providers: