The gcp:compute/imageIamMember:ImageIamMember resource, part of the Pulumi GCP provider, grants IAM permissions on Compute Engine images by adding individual members to roles without replacing existing permissions. This guide focuses on three capabilities: single-member grants, multi-member role bindings, and time-based access with IAM Conditions.
Image IAM resources reference existing Compute Engine images by name. The examples are intentionally small. Combine them with your own image resources and organizational IAM structure.
Grant image access to a single member
Teams sharing custom VM images across projects often need to grant specific users or service accounts access without modifying the entire policy.
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 identifies who receives access (user, service account, group, or domain). The role property specifies what they can do; roles/compute.imageUser allows launching VMs from the image. ImageIamMember is non-authoritative, meaning it adds this member without affecting other members or roles on the image.
Grant time-limited access with IAM Conditions
Temporary access grants expire automatically when you attach IAM Conditions to member bindings, useful for contractor access or time-boxed testing.
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",
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
member = gcp.compute.ImageIamMember("member",
project=example["project"],
image=example["name"],
role="roles/compute.imageUser",
member="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.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"),
Condition: &compute.ImageIamMemberConditionArgs{
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 member = new Gcp.Compute.ImageIamMember("member", new()
{
Project = example.Project,
Image = example.Name,
Role = "roles/compute.imageUser",
Member = "user:jane@example.com",
Condition = new Gcp.Compute.Inputs.ImageIamMemberConditionArgs
{
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.ImageIamMember;
import com.pulumi.gcp.compute.ImageIamMemberArgs;
import com.pulumi.gcp.compute.inputs.ImageIamMemberConditionArgs;
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")
.condition(ImageIamMemberConditionArgs.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:
member:
type: gcp:compute:ImageIamMember
properties:
project: ${example.project}
image: ${example.name}
role: roles/compute.imageUser
member: 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 time-based restrictions to the member grant. The expression uses CEL (Common Expression Language) to define when access is valid; this example expires at midnight on 2020-01-01. The title and description document the condition’s purpose. When the condition evaluates to false, the member loses access automatically.
Grant image access to multiple members at once
When multiple users need the same role, ImageIamBinding grants that role to a list of members in one resource.
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 should have the role. ImageIamBinding is authoritative for the specified role, meaning it replaces any existing members for roles/compute.imageUser. Other roles on the image remain unchanged. Use ImageIamMember instead if you need to preserve existing members for the same role.
Beyond these examples
These snippets focus on specific image IAM features: single-member grants, multi-member role bindings, and time-based IAM Conditions. They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as Compute Engine images in the project. They focus on granting permissions rather than creating images or managing full IAM policies.
To keep things focused, common IAM patterns are omitted, including:
- Full policy replacement (ImageIamPolicy)
- Complex IAM Condition expressions (resource attributes, request context)
- Custom role definitions
- Cross-project image sharing patterns
These omissions are intentional: the goal is to illustrate how each IAM grant type is wired, not provide drop-in access control modules. See the Compute Image IAM Member resource reference for all available configuration options.
Let's manage GCP Compute Image IAM Permissions
Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.
Try Pulumi Cloud for FREEFrequently Asked Questions
Resource Selection & Conflicts
ImageIamPolicy cannot be used with ImageIamBinding or ImageIamMember because they will fight over the policy. Additionally, ImageIamBinding and ImageIamMember will conflict if they manage the same role.Choose based on your needs:
ImageIamPolicy: Authoritative, replaces the entire IAM policyImageIamBinding: Authoritative for a specific role, preserves other rolesImageIamMember: Non-authoritative, adds a single member to a role while preserving other members
IAM Member Configuration
You can use:
allUsersorallAuthenticatedUsersfor public/authenticated accessuser:{email}for specific Google accountsserviceAccount:{email}for service accountsgroup:{email}for Google groupsdomain:{domain}for G Suite domainsprojectOwner:projectid,projectEditor:projectid, orprojectViewer:projectidfor project roles- Federated identities using principal identifiers (e.g.,
principal://iam.googleapis.com/...)
member to serviceAccount:{emailid}, for example: serviceAccount:my-app@appspot.gserviceaccount.com.[projects|organizations]/{parent-name}/roles/{role-name}.IAM Conditions & Advanced Features
condition property with title, description, and expression fields. For example, to expire access: expression: "request.time < timestamp(\"2020-01-01T00:00:00Z\")".Resource Properties & Immutability
image, member, project, role, and condition. You must recreate the resource to change any of these.project property. If not provided, it will be parsed from the image identifier or fall back to the provider’s default project.