Manage GCP Instant Snapshot IAM Policies

The gcp:compute/instantSnapshotIamPolicy:InstantSnapshotIamPolicy resource, part of the Pulumi GCP provider, manages IAM access control for Compute Engine instant snapshots. This guide focuses on three capabilities: authoritative policy replacement, role-based member assignment, and time-based conditional access.

The Pulumi GCP provider offers three related resources for instant snapshot IAM: InstantSnapshotIamPolicy (replaces entire policy), InstantSnapshotIamBinding (manages one role’s members), and InstantSnapshotIamMember (adds individual members). All three reference existing snapshots by name, project, and zone. The examples are intentionally small. Combine them with your own snapshot resources and organizational IAM structure.

Replace the entire IAM policy for a snapshot

When you need complete control over snapshot access, you can set the entire IAM policy at once, replacing any existing permissions.

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

const admin = gcp.organizations.getIAMPolicy({
    bindings: [{
        role: "roles/compute.storageAdmin",
        members: ["user:jane@example.com"],
    }],
});
const policy = new gcp.compute.InstantSnapshotIamPolicy("policy", {
    project: _default.project,
    zone: _default.zone,
    name: _default.name,
    policyData: admin.then(admin => admin.policyData),
});
import pulumi
import pulumi_gcp as gcp

admin = gcp.organizations.get_iam_policy(bindings=[{
    "role": "roles/compute.storageAdmin",
    "members": ["user:jane@example.com"],
}])
policy = gcp.compute.InstantSnapshotIamPolicy("policy",
    project=default["project"],
    zone=default["zone"],
    name=default["name"],
    policy_data=admin.policy_data)
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		admin, err := organizations.LookupIAMPolicy(ctx, &organizations.LookupIAMPolicyArgs{
			Bindings: []organizations.GetIAMPolicyBinding{
				{
					Role: "roles/compute.storageAdmin",
					Members: []string{
						"user:jane@example.com",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = compute.NewInstantSnapshotIamPolicy(ctx, "policy", &compute.InstantSnapshotIamPolicyArgs{
			Project:    pulumi.Any(_default.Project),
			Zone:       pulumi.Any(_default.Zone),
			Name:       pulumi.Any(_default.Name),
			PolicyData: pulumi.String(admin.PolicyData),
		})
		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 admin = Gcp.Organizations.GetIAMPolicy.Invoke(new()
    {
        Bindings = new[]
        {
            new Gcp.Organizations.Inputs.GetIAMPolicyBindingInputArgs
            {
                Role = "roles/compute.storageAdmin",
                Members = new[]
                {
                    "user:jane@example.com",
                },
            },
        },
    });

    var policy = new Gcp.Compute.InstantSnapshotIamPolicy("policy", new()
    {
        Project = @default.Project,
        Zone = @default.Zone,
        Name = @default.Name,
        PolicyData = admin.Apply(getIAMPolicyResult => getIAMPolicyResult.PolicyData),
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetIAMPolicyArgs;
import com.pulumi.gcp.compute.InstantSnapshotIamPolicy;
import com.pulumi.gcp.compute.InstantSnapshotIamPolicyArgs;
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) {
        final var admin = OrganizationsFunctions.getIAMPolicy(GetIAMPolicyArgs.builder()
            .bindings(GetIAMPolicyBindingArgs.builder()
                .role("roles/compute.storageAdmin")
                .members("user:jane@example.com")
                .build())
            .build());

        var policy = new InstantSnapshotIamPolicy("policy", InstantSnapshotIamPolicyArgs.builder()
            .project(default_.project())
            .zone(default_.zone())
            .name(default_.name())
            .policyData(admin.policyData())
            .build());

    }
}
resources:
  policy:
    type: gcp:compute:InstantSnapshotIamPolicy
    properties:
      project: ${default.project}
      zone: ${default.zone}
      name: ${default.name}
      policyData: ${admin.policyData}
variables:
  admin:
    fn::invoke:
      function: gcp:organizations:getIAMPolicy
      arguments:
        bindings:
          - role: roles/compute.storageAdmin
            members:
              - user:jane@example.com

The InstantSnapshotIamPolicy resource is authoritative: it replaces the snapshot’s entire IAM policy with the policyData you provide. The getIAMPolicy data source constructs the policy document from bindings. The project, zone, and name properties identify which snapshot to configure. This approach gives you full control but requires listing all desired permissions in one place.

Grant a role to multiple members at once

Teams often need to grant the same role to several users or service accounts without affecting other roles.

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 InstantSnapshotIamBinding resource is authoritative for a single role: it sets the complete member list for that role while preserving other roles on the snapshot. The members property accepts a list of identities (users, service accounts, groups). This approach works well when you manage all members for a role together, but it will overwrite any members added outside this resource.

Add a single member to a role incrementally

When you want to grant access to one additional user without modifying existing members, you can add them individually.

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 InstantSnapshotIamMember resource is non-authoritative: it adds one member to a role without affecting other members or roles. The member property specifies a single identity. This approach lets you grant access incrementally, making it useful when different teams manage different users’ access to the same snapshot.

Set time-based access with IAM Conditions

Access requirements sometimes include expiration dates or other conditional logic, such as granting temporary permissions that automatically expire.

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

const admin = gcp.organizations.getIAMPolicy({
    bindings: [{
        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\")",
        },
    }],
});
const policy = new gcp.compute.InstantSnapshotIamPolicy("policy", {
    project: _default.project,
    zone: _default.zone,
    name: _default.name,
    policyData: admin.then(admin => admin.policyData),
});
import pulumi
import pulumi_gcp as gcp

admin = gcp.organizations.get_iam_policy(bindings=[{
    "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\")",
    },
}])
policy = gcp.compute.InstantSnapshotIamPolicy("policy",
    project=default["project"],
    zone=default["zone"],
    name=default["name"],
    policy_data=admin.policy_data)
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		admin, err := organizations.LookupIAMPolicy(ctx, &organizations.LookupIAMPolicyArgs{
			Bindings: []organizations.GetIAMPolicyBinding{
				{
					Role: "roles/compute.storageAdmin",
					Members: []string{
						"user:jane@example.com",
					},
					Condition: {
						Title:       "expires_after_2019_12_31",
						Description: pulumi.StringRef("Expiring at midnight of 2019-12-31"),
						Expression:  "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = compute.NewInstantSnapshotIamPolicy(ctx, "policy", &compute.InstantSnapshotIamPolicyArgs{
			Project:    pulumi.Any(_default.Project),
			Zone:       pulumi.Any(_default.Zone),
			Name:       pulumi.Any(_default.Name),
			PolicyData: pulumi.String(admin.PolicyData),
		})
		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 admin = Gcp.Organizations.GetIAMPolicy.Invoke(new()
    {
        Bindings = new[]
        {
            new Gcp.Organizations.Inputs.GetIAMPolicyBindingInputArgs
            {
                Role = "roles/compute.storageAdmin",
                Members = new[]
                {
                    "user:jane@example.com",
                },
                Condition = new Gcp.Organizations.Inputs.GetIAMPolicyBindingConditionInputArgs
                {
                    Title = "expires_after_2019_12_31",
                    Description = "Expiring at midnight of 2019-12-31",
                    Expression = "request.time < timestamp(\"2020-01-01T00:00:00Z\")",
                },
            },
        },
    });

    var policy = new Gcp.Compute.InstantSnapshotIamPolicy("policy", new()
    {
        Project = @default.Project,
        Zone = @default.Zone,
        Name = @default.Name,
        PolicyData = admin.Apply(getIAMPolicyResult => getIAMPolicyResult.PolicyData),
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetIAMPolicyArgs;
import com.pulumi.gcp.compute.InstantSnapshotIamPolicy;
import com.pulumi.gcp.compute.InstantSnapshotIamPolicyArgs;
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) {
        final var admin = OrganizationsFunctions.getIAMPolicy(GetIAMPolicyArgs.builder()
            .bindings(GetIAMPolicyBindingArgs.builder()
                .role("roles/compute.storageAdmin")
                .members("user:jane@example.com")
                .condition(GetIAMPolicyBindingConditionArgs.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())
            .build());

        var policy = new InstantSnapshotIamPolicy("policy", InstantSnapshotIamPolicyArgs.builder()
            .project(default_.project())
            .zone(default_.zone())
            .name(default_.name())
            .policyData(admin.policyData())
            .build());

    }
}
resources:
  policy:
    type: gcp:compute:InstantSnapshotIamPolicy
    properties:
      project: ${default.project}
      zone: ${default.zone}
      name: ${default.name}
      policyData: ${admin.policyData}
variables:
  admin:
    fn::invoke:
      function: gcp:organizations:getIAMPolicy
      arguments:
        bindings:
          - 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")

IAM Conditions add logic to role bindings through the condition property. The expression uses CEL (Common Expression Language) to define when the binding applies. Here, the timestamp comparison automatically revokes access after December 31, 2019. The title and description document the condition’s purpose. Conditions work with all three IAM resources (Policy, Binding, Member), but have limitations documented in the GCP IAM Conditions overview.

Beyond these examples

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

The examples reference pre-existing infrastructure such as instant snapshots (by name, project, zone). They focus on configuring IAM permissions rather than creating the snapshots themselves.

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

  • Resource conflict rules (Policy vs Binding vs Member)
  • IAM Conditions limitations and edge cases
  • Custom role definitions and management
  • Import syntax for existing IAM configurations

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

Let's manage GCP Instant Snapshot IAM Policies

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
Which IAM resource should I use for managing instant snapshot permissions?

Choose based on your needs:

  • gcp.compute.InstantSnapshotIamPolicy - Authoritative, replaces the entire IAM policy
  • gcp.compute.InstantSnapshotIamBinding - Authoritative for a specific role, preserves other roles
  • gcp.compute.InstantSnapshotIamMember - Non-authoritative, adds a single member to a role while preserving other members
Can I use InstantSnapshotIamPolicy with InstantSnapshotIamBinding or InstantSnapshotIamMember?
No, gcp.compute.InstantSnapshotIamPolicy cannot be used with gcp.compute.InstantSnapshotIamBinding or gcp.compute.InstantSnapshotIamMember because they will conflict over the policy configuration.
Can I use InstantSnapshotIamBinding and InstantSnapshotIamMember together?
Yes, but only if they manage different roles. Using both resources for the same role will cause conflicts.
IAM Conditions
How do I add IAM Conditions to my instant snapshot permissions?
Add a condition block with title, description, and expression fields. For example, to create a time-based condition, use an expression like request.time < timestamp("2020-01-01T00:00:00Z").
Are there any limitations when using IAM Conditions?
Yes, IAM Conditions have known limitations. Review the GCP documentation on IAM Conditions limitations if you encounter issues.

Using a different cloud?

Explore security guides for other cloud providers: