The gcp:compute/instantSnapshotIamBinding:InstantSnapshotIamBinding resource, part of the Pulumi GCP provider, grants IAM roles to multiple members on instant snapshots while preserving other role assignments. This guide focuses on three capabilities: binding roles to multiple members, adding time-based conditional access, and incrementally adding single members.
IAM bindings reference existing instant snapshots by name, zone, and project. The snapshot must exist before you attach policies. The examples are intentionally small. Combine them with your own snapshot resources and identity management.
Grant a role to multiple members at once
Teams managing snapshot access 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.InstantSnapshotIamBinding("binding", {
project: _default.project,
zone: _default.zone,
name: _default.name,
role: "roles/compute.storageAdmin",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
binding = gcp.compute.InstantSnapshotIamBinding("binding",
project=default["project"],
zone=default["zone"],
name=default["name"],
role="roles/compute.storageAdmin",
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.NewInstantSnapshotIamBinding(ctx, "binding", &compute.InstantSnapshotIamBindingArgs{
Project: pulumi.Any(_default.Project),
Zone: pulumi.Any(_default.Zone),
Name: pulumi.Any(_default.Name),
Role: pulumi.String("roles/compute.storageAdmin"),
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.InstantSnapshotIamBinding("binding", new()
{
Project = @default.Project,
Zone = @default.Zone,
Name = @default.Name,
Role = "roles/compute.storageAdmin",
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.InstantSnapshotIamBinding;
import com.pulumi.gcp.compute.InstantSnapshotIamBindingArgs;
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 InstantSnapshotIamBinding("binding", InstantSnapshotIamBindingArgs.builder()
.project(default_.project())
.zone(default_.zone())
.name(default_.name())
.role("roles/compute.storageAdmin")
.members("user:jane@example.com")
.build());
}
}
resources:
binding:
type: gcp:compute:InstantSnapshotIamBinding
properties:
project: ${default.project}
zone: ${default.zone}
name: ${default.name}
role: roles/compute.storageAdmin
members:
- user:jane@example.com
The role property specifies which permission set to grant. The members array lists all identities that receive the role. InstantSnapshotIamBinding is authoritative for this specific role, meaning it replaces any previous member list for this role while leaving other roles untouched. The name, zone, and project properties identify which snapshot receives the binding.
Add time-based access with IAM Conditions
Temporary access grants expire automatically when you attach IAM Conditions to role bindings, preventing manual cleanup.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const binding = new gcp.compute.InstantSnapshotIamBinding("binding", {
project: _default.project,
zone: _default.zone,
name: _default.name,
role: "roles/compute.storageAdmin",
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.InstantSnapshotIamBinding("binding",
project=default["project"],
zone=default["zone"],
name=default["name"],
role="roles/compute.storageAdmin",
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.NewInstantSnapshotIamBinding(ctx, "binding", &compute.InstantSnapshotIamBindingArgs{
Project: pulumi.Any(_default.Project),
Zone: pulumi.Any(_default.Zone),
Name: pulumi.Any(_default.Name),
Role: pulumi.String("roles/compute.storageAdmin"),
Members: pulumi.StringArray{
pulumi.String("user:jane@example.com"),
},
Condition: &compute.InstantSnapshotIamBindingConditionArgs{
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.InstantSnapshotIamBinding("binding", new()
{
Project = @default.Project,
Zone = @default.Zone,
Name = @default.Name,
Role = "roles/compute.storageAdmin",
Members = new[]
{
"user:jane@example.com",
},
Condition = new Gcp.Compute.Inputs.InstantSnapshotIamBindingConditionArgs
{
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.InstantSnapshotIamBinding;
import com.pulumi.gcp.compute.InstantSnapshotIamBindingArgs;
import com.pulumi.gcp.compute.inputs.InstantSnapshotIamBindingConditionArgs;
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 InstantSnapshotIamBinding("binding", InstantSnapshotIamBindingArgs.builder()
.project(default_.project())
.zone(default_.zone())
.name(default_.name())
.role("roles/compute.storageAdmin")
.members("user:jane@example.com")
.condition(InstantSnapshotIamBindingConditionArgs.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:InstantSnapshotIamBinding
properties:
project: ${default.project}
zone: ${default.zone}
name: ${default.name}
role: roles/compute.storageAdmin
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 role binding. The expression property uses CEL (Common Expression Language) to define when access is valid. Here, the timestamp comparison automatically revokes access after December 31, 2019. The title and description properties document the condition’s purpose for auditing.
Add a single member to an existing role
When you need to grant access to one additional user without affecting existing members, InstantSnapshotIamMember adds the new identity incrementally.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const member = new gcp.compute.InstantSnapshotIamMember("member", {
project: _default.project,
zone: _default.zone,
name: _default.name,
role: "roles/compute.storageAdmin",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
member = gcp.compute.InstantSnapshotIamMember("member",
project=default["project"],
zone=default["zone"],
name=default["name"],
role="roles/compute.storageAdmin",
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.NewInstantSnapshotIamMember(ctx, "member", &compute.InstantSnapshotIamMemberArgs{
Project: pulumi.Any(_default.Project),
Zone: pulumi.Any(_default.Zone),
Name: pulumi.Any(_default.Name),
Role: pulumi.String("roles/compute.storageAdmin"),
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.InstantSnapshotIamMember("member", new()
{
Project = @default.Project,
Zone = @default.Zone,
Name = @default.Name,
Role = "roles/compute.storageAdmin",
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.InstantSnapshotIamMember;
import com.pulumi.gcp.compute.InstantSnapshotIamMemberArgs;
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 InstantSnapshotIamMember("member", InstantSnapshotIamMemberArgs.builder()
.project(default_.project())
.zone(default_.zone())
.name(default_.name())
.role("roles/compute.storageAdmin")
.member("user:jane@example.com")
.build());
}
}
resources:
member:
type: gcp:compute:InstantSnapshotIamMember
properties:
project: ${default.project}
zone: ${default.zone}
name: ${default.name}
role: roles/compute.storageAdmin
member: user:jane@example.com
The member property specifies a single identity to add. Unlike InstantSnapshotIamBinding, this resource is non-authoritative: it adds one member without replacing the existing member list for the role. Use this when you want to grant access without knowing or affecting who else has the role.
Beyond these examples
These snippets focus on specific IAM binding features: role binding with multiple members, time-based conditional access, and incremental member addition. They’re intentionally minimal rather than complete access control configurations.
The examples reference pre-existing infrastructure such as instant snapshots (by name, zone, project) and IAM principals (users, service accounts, groups). They focus on configuring access rather than creating the underlying resources.
To keep things focused, common IAM patterns are omitted, including:
- Full policy replacement (InstantSnapshotIamPolicy)
- Custom role definitions and formatting
- Condition limitations and troubleshooting
- Policy conflict resolution between resource types
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 InstantSnapshotIamBinding resource reference for all available configuration options.
Let's manage GCP Instant Snapshot IAM Bindings
Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.
Try Pulumi Cloud for FREEFrequently Asked Questions
Resource Conflicts & Compatibility
gcp.compute.InstantSnapshotIamPolicy cannot be used with gcp.compute.InstantSnapshotIamBinding or gcp.compute.InstantSnapshotIamMember because they will conflict over the policy state.IAM Configuration & Roles
role, name, project, zone, and condition properties are all immutable and cannot be modified after the resource is created.[projects|organizations]/{parent-name}/roles/{role-name}. For example, projects/my-project/roles/my-custom-role.gcp.compute.InstantSnapshotIamBinding per role. Each binding manages a different role’s member list.Access Control & Members
You can grant access to:
- Users:
user:alice@gmail.com - Service accounts:
serviceAccount:my-app@appspot.gserviceaccount.com - Groups:
group:admins@example.com - Domains:
domain:example.com - Project roles:
projectOwner:my-project,projectEditor:my-project,projectViewer:my-project - Special identifiers:
allUsers,allAuthenticatedUsers - Federated identities:
principal://iam.googleapis.com/locations/global/workforcePools/...
Advanced Features
condition property with title, description, and expression fields. For example, to expire access at a specific date: expression: "request.time < timestamp(\"2020-01-01T00:00:00Z\")".