Create GCP Colab Notebook Runtimes

The gcp:colab/runtime:Runtime resource, part of the Pulumi GCP provider, provisions a Google-managed VM that executes code in Colab Enterprise notebooks. This guide focuses on three capabilities: template-based runtime creation, state control, and automatic upgrade configuration.

Runtimes reference RuntimeTemplate resources that define machine specs, network access, and security settings. The examples are intentionally small. Combine them with your own templates and user management.

Create a runtime from a template

Teams running Jupyter notebooks start by creating a runtime from a template that defines machine type and network access.

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

const myTemplate = new gcp.colab.RuntimeTemplate("my_template", {
    name: "colab-runtime",
    displayName: "Runtime template basic",
    location: "us-central1",
    machineSpec: {
        machineType: "e2-standard-4",
    },
    networkSpec: {
        enableInternetAccess: true,
    },
});
const runtime = new gcp.colab.Runtime("runtime", {
    name: "colab-runtime",
    location: "us-central1",
    notebookRuntimeTemplateRef: {
        notebookRuntimeTemplate: myTemplate.id,
    },
    displayName: "Runtime basic",
    runtimeUser: "gterraformtestuser@gmail.com",
}, {
    dependsOn: [myTemplate],
});
import pulumi
import pulumi_gcp as gcp

my_template = gcp.colab.RuntimeTemplate("my_template",
    name="colab-runtime",
    display_name="Runtime template basic",
    location="us-central1",
    machine_spec={
        "machine_type": "e2-standard-4",
    },
    network_spec={
        "enable_internet_access": True,
    })
runtime = gcp.colab.Runtime("runtime",
    name="colab-runtime",
    location="us-central1",
    notebook_runtime_template_ref={
        "notebook_runtime_template": my_template.id,
    },
    display_name="Runtime basic",
    runtime_user="gterraformtestuser@gmail.com",
    opts = pulumi.ResourceOptions(depends_on=[my_template]))
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myTemplate, err := colab.NewRuntimeTemplate(ctx, "my_template", &colab.RuntimeTemplateArgs{
			Name:        pulumi.String("colab-runtime"),
			DisplayName: pulumi.String("Runtime template basic"),
			Location:    pulumi.String("us-central1"),
			MachineSpec: &colab.RuntimeTemplateMachineSpecArgs{
				MachineType: pulumi.String("e2-standard-4"),
			},
			NetworkSpec: &colab.RuntimeTemplateNetworkSpecArgs{
				EnableInternetAccess: pulumi.Bool(true),
			},
		})
		if err != nil {
			return err
		}
		_, err = colab.NewRuntime(ctx, "runtime", &colab.RuntimeArgs{
			Name:     pulumi.String("colab-runtime"),
			Location: pulumi.String("us-central1"),
			NotebookRuntimeTemplateRef: &colab.RuntimeNotebookRuntimeTemplateRefArgs{
				NotebookRuntimeTemplate: myTemplate.ID(),
			},
			DisplayName: pulumi.String("Runtime basic"),
			RuntimeUser: pulumi.String("gterraformtestuser@gmail.com"),
		}, pulumi.DependsOn([]pulumi.Resource{
			myTemplate,
		}))
		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 myTemplate = new Gcp.Colab.RuntimeTemplate("my_template", new()
    {
        Name = "colab-runtime",
        DisplayName = "Runtime template basic",
        Location = "us-central1",
        MachineSpec = new Gcp.Colab.Inputs.RuntimeTemplateMachineSpecArgs
        {
            MachineType = "e2-standard-4",
        },
        NetworkSpec = new Gcp.Colab.Inputs.RuntimeTemplateNetworkSpecArgs
        {
            EnableInternetAccess = true,
        },
    });

    var runtime = new Gcp.Colab.Runtime("runtime", new()
    {
        Name = "colab-runtime",
        Location = "us-central1",
        NotebookRuntimeTemplateRef = new Gcp.Colab.Inputs.RuntimeNotebookRuntimeTemplateRefArgs
        {
            NotebookRuntimeTemplate = myTemplate.Id,
        },
        DisplayName = "Runtime basic",
        RuntimeUser = "gterraformtestuser@gmail.com",
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            myTemplate,
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.colab.RuntimeTemplate;
import com.pulumi.gcp.colab.RuntimeTemplateArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateMachineSpecArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateNetworkSpecArgs;
import com.pulumi.gcp.colab.Runtime;
import com.pulumi.gcp.colab.RuntimeArgs;
import com.pulumi.gcp.colab.inputs.RuntimeNotebookRuntimeTemplateRefArgs;
import com.pulumi.resources.CustomResourceOptions;
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 myTemplate = new RuntimeTemplate("myTemplate", RuntimeTemplateArgs.builder()
            .name("colab-runtime")
            .displayName("Runtime template basic")
            .location("us-central1")
            .machineSpec(RuntimeTemplateMachineSpecArgs.builder()
                .machineType("e2-standard-4")
                .build())
            .networkSpec(RuntimeTemplateNetworkSpecArgs.builder()
                .enableInternetAccess(true)
                .build())
            .build());

        var runtime = new Runtime("runtime", RuntimeArgs.builder()
            .name("colab-runtime")
            .location("us-central1")
            .notebookRuntimeTemplateRef(RuntimeNotebookRuntimeTemplateRefArgs.builder()
                .notebookRuntimeTemplate(myTemplate.id())
                .build())
            .displayName("Runtime basic")
            .runtimeUser("gterraformtestuser@gmail.com")
            .build(), CustomResourceOptions.builder()
                .dependsOn(myTemplate)
                .build());

    }
}
resources:
  myTemplate:
    type: gcp:colab:RuntimeTemplate
    name: my_template
    properties:
      name: colab-runtime
      displayName: Runtime template basic
      location: us-central1
      machineSpec:
        machineType: e2-standard-4
      networkSpec:
        enableInternetAccess: true
  runtime:
    type: gcp:colab:Runtime
    properties:
      name: colab-runtime
      location: us-central1
      notebookRuntimeTemplateRef:
        notebookRuntimeTemplate: ${myTemplate.id}
      displayName: Runtime basic
      runtimeUser: gterraformtestuser@gmail.com
    options:
      dependsOn:
        - ${myTemplate}

The notebookRuntimeTemplateRef property links to a RuntimeTemplate that specifies the VM configuration. The runtimeUser property assigns ownership to a specific email address. When created, the runtime provisions a VM and enters RUNNING state by default.

Control runtime state at creation

Runtimes can be created in a stopped state to defer VM costs until the notebook is needed.

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

const myTemplate = new gcp.colab.RuntimeTemplate("my_template", {
    name: "colab-runtime",
    displayName: "Runtime template basic",
    location: "us-central1",
    machineSpec: {
        machineType: "e2-standard-4",
    },
    networkSpec: {
        enableInternetAccess: true,
    },
});
const runtime = new gcp.colab.Runtime("runtime", {
    name: "colab-runtime",
    location: "us-central1",
    notebookRuntimeTemplateRef: {
        notebookRuntimeTemplate: myTemplate.id,
    },
    desiredState: "STOPPED",
    displayName: "Runtime stopped",
    runtimeUser: "gterraformtestuser@gmail.com",
}, {
    dependsOn: [myTemplate],
});
import pulumi
import pulumi_gcp as gcp

my_template = gcp.colab.RuntimeTemplate("my_template",
    name="colab-runtime",
    display_name="Runtime template basic",
    location="us-central1",
    machine_spec={
        "machine_type": "e2-standard-4",
    },
    network_spec={
        "enable_internet_access": True,
    })
runtime = gcp.colab.Runtime("runtime",
    name="colab-runtime",
    location="us-central1",
    notebook_runtime_template_ref={
        "notebook_runtime_template": my_template.id,
    },
    desired_state="STOPPED",
    display_name="Runtime stopped",
    runtime_user="gterraformtestuser@gmail.com",
    opts = pulumi.ResourceOptions(depends_on=[my_template]))
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myTemplate, err := colab.NewRuntimeTemplate(ctx, "my_template", &colab.RuntimeTemplateArgs{
			Name:        pulumi.String("colab-runtime"),
			DisplayName: pulumi.String("Runtime template basic"),
			Location:    pulumi.String("us-central1"),
			MachineSpec: &colab.RuntimeTemplateMachineSpecArgs{
				MachineType: pulumi.String("e2-standard-4"),
			},
			NetworkSpec: &colab.RuntimeTemplateNetworkSpecArgs{
				EnableInternetAccess: pulumi.Bool(true),
			},
		})
		if err != nil {
			return err
		}
		_, err = colab.NewRuntime(ctx, "runtime", &colab.RuntimeArgs{
			Name:     pulumi.String("colab-runtime"),
			Location: pulumi.String("us-central1"),
			NotebookRuntimeTemplateRef: &colab.RuntimeNotebookRuntimeTemplateRefArgs{
				NotebookRuntimeTemplate: myTemplate.ID(),
			},
			DesiredState: pulumi.String("STOPPED"),
			DisplayName:  pulumi.String("Runtime stopped"),
			RuntimeUser:  pulumi.String("gterraformtestuser@gmail.com"),
		}, pulumi.DependsOn([]pulumi.Resource{
			myTemplate,
		}))
		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 myTemplate = new Gcp.Colab.RuntimeTemplate("my_template", new()
    {
        Name = "colab-runtime",
        DisplayName = "Runtime template basic",
        Location = "us-central1",
        MachineSpec = new Gcp.Colab.Inputs.RuntimeTemplateMachineSpecArgs
        {
            MachineType = "e2-standard-4",
        },
        NetworkSpec = new Gcp.Colab.Inputs.RuntimeTemplateNetworkSpecArgs
        {
            EnableInternetAccess = true,
        },
    });

    var runtime = new Gcp.Colab.Runtime("runtime", new()
    {
        Name = "colab-runtime",
        Location = "us-central1",
        NotebookRuntimeTemplateRef = new Gcp.Colab.Inputs.RuntimeNotebookRuntimeTemplateRefArgs
        {
            NotebookRuntimeTemplate = myTemplate.Id,
        },
        DesiredState = "STOPPED",
        DisplayName = "Runtime stopped",
        RuntimeUser = "gterraformtestuser@gmail.com",
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            myTemplate,
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.colab.RuntimeTemplate;
import com.pulumi.gcp.colab.RuntimeTemplateArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateMachineSpecArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateNetworkSpecArgs;
import com.pulumi.gcp.colab.Runtime;
import com.pulumi.gcp.colab.RuntimeArgs;
import com.pulumi.gcp.colab.inputs.RuntimeNotebookRuntimeTemplateRefArgs;
import com.pulumi.resources.CustomResourceOptions;
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 myTemplate = new RuntimeTemplate("myTemplate", RuntimeTemplateArgs.builder()
            .name("colab-runtime")
            .displayName("Runtime template basic")
            .location("us-central1")
            .machineSpec(RuntimeTemplateMachineSpecArgs.builder()
                .machineType("e2-standard-4")
                .build())
            .networkSpec(RuntimeTemplateNetworkSpecArgs.builder()
                .enableInternetAccess(true)
                .build())
            .build());

        var runtime = new Runtime("runtime", RuntimeArgs.builder()
            .name("colab-runtime")
            .location("us-central1")
            .notebookRuntimeTemplateRef(RuntimeNotebookRuntimeTemplateRefArgs.builder()
                .notebookRuntimeTemplate(myTemplate.id())
                .build())
            .desiredState("STOPPED")
            .displayName("Runtime stopped")
            .runtimeUser("gterraformtestuser@gmail.com")
            .build(), CustomResourceOptions.builder()
                .dependsOn(myTemplate)
                .build());

    }
}
resources:
  myTemplate:
    type: gcp:colab:RuntimeTemplate
    name: my_template
    properties:
      name: colab-runtime
      displayName: Runtime template basic
      location: us-central1
      machineSpec:
        machineType: e2-standard-4
      networkSpec:
        enableInternetAccess: true
  runtime:
    type: gcp:colab:Runtime
    properties:
      name: colab-runtime
      location: us-central1
      notebookRuntimeTemplateRef:
        notebookRuntimeTemplate: ${myTemplate.id}
      desiredState: STOPPED
      displayName: Runtime stopped
      runtimeUser: gterraformtestuser@gmail.com
    options:
      dependsOn:
        - ${myTemplate}

The desiredState property controls whether the VM starts immediately. Set it to STOPPED to create the runtime without provisioning compute resources. You can start it later by changing desiredState to RUNNING.

Enable automatic upgrades and add metadata

Production runtimes often need automatic upgrades for security patches and feature updates.

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

const myTemplate = new gcp.colab.RuntimeTemplate("my_template", {
    name: "colab-runtime",
    displayName: "Runtime template full",
    location: "us-central1",
    description: "Full runtime template",
    machineSpec: {
        machineType: "n1-standard-2",
        acceleratorType: "NVIDIA_TESLA_T4",
        acceleratorCount: 1,
    },
    dataPersistentDiskSpec: {
        diskType: "pd-standard",
        diskSizeGb: "200",
    },
    networkSpec: {
        enableInternetAccess: true,
    },
    labels: {
        k: "val",
    },
    idleShutdownConfig: {
        idleTimeout: "3600s",
    },
    eucConfig: {
        eucDisabled: true,
    },
    shieldedVmConfig: {
        enableSecureBoot: true,
    },
    networkTags: [
        "abc",
        "def",
    ],
    encryptionSpec: {
        kmsKeyName: "my-crypto-key",
    },
});
const runtime = new gcp.colab.Runtime("runtime", {
    name: "colab-runtime",
    location: "us-central1",
    notebookRuntimeTemplateRef: {
        notebookRuntimeTemplate: myTemplate.id,
    },
    displayName: "Runtime full",
    runtimeUser: "gterraformtestuser@gmail.com",
    description: "Full runtime",
    desiredState: "ACTIVE",
    autoUpgrade: true,
}, {
    dependsOn: [myTemplate],
});
import pulumi
import pulumi_gcp as gcp

my_template = gcp.colab.RuntimeTemplate("my_template",
    name="colab-runtime",
    display_name="Runtime template full",
    location="us-central1",
    description="Full runtime template",
    machine_spec={
        "machine_type": "n1-standard-2",
        "accelerator_type": "NVIDIA_TESLA_T4",
        "accelerator_count": 1,
    },
    data_persistent_disk_spec={
        "disk_type": "pd-standard",
        "disk_size_gb": "200",
    },
    network_spec={
        "enable_internet_access": True,
    },
    labels={
        "k": "val",
    },
    idle_shutdown_config={
        "idle_timeout": "3600s",
    },
    euc_config={
        "euc_disabled": True,
    },
    shielded_vm_config={
        "enable_secure_boot": True,
    },
    network_tags=[
        "abc",
        "def",
    ],
    encryption_spec={
        "kms_key_name": "my-crypto-key",
    })
runtime = gcp.colab.Runtime("runtime",
    name="colab-runtime",
    location="us-central1",
    notebook_runtime_template_ref={
        "notebook_runtime_template": my_template.id,
    },
    display_name="Runtime full",
    runtime_user="gterraformtestuser@gmail.com",
    description="Full runtime",
    desired_state="ACTIVE",
    auto_upgrade=True,
    opts = pulumi.ResourceOptions(depends_on=[my_template]))
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myTemplate, err := colab.NewRuntimeTemplate(ctx, "my_template", &colab.RuntimeTemplateArgs{
			Name:        pulumi.String("colab-runtime"),
			DisplayName: pulumi.String("Runtime template full"),
			Location:    pulumi.String("us-central1"),
			Description: pulumi.String("Full runtime template"),
			MachineSpec: &colab.RuntimeTemplateMachineSpecArgs{
				MachineType:      pulumi.String("n1-standard-2"),
				AcceleratorType:  pulumi.String("NVIDIA_TESLA_T4"),
				AcceleratorCount: pulumi.Int(1),
			},
			DataPersistentDiskSpec: &colab.RuntimeTemplateDataPersistentDiskSpecArgs{
				DiskType:   pulumi.String("pd-standard"),
				DiskSizeGb: pulumi.String("200"),
			},
			NetworkSpec: &colab.RuntimeTemplateNetworkSpecArgs{
				EnableInternetAccess: pulumi.Bool(true),
			},
			Labels: pulumi.StringMap{
				"k": pulumi.String("val"),
			},
			IdleShutdownConfig: &colab.RuntimeTemplateIdleShutdownConfigArgs{
				IdleTimeout: pulumi.String("3600s"),
			},
			EucConfig: &colab.RuntimeTemplateEucConfigArgs{
				EucDisabled: pulumi.Bool(true),
			},
			ShieldedVmConfig: &colab.RuntimeTemplateShieldedVmConfigArgs{
				EnableSecureBoot: pulumi.Bool(true),
			},
			NetworkTags: pulumi.StringArray{
				pulumi.String("abc"),
				pulumi.String("def"),
			},
			EncryptionSpec: &colab.RuntimeTemplateEncryptionSpecArgs{
				KmsKeyName: pulumi.String("my-crypto-key"),
			},
		})
		if err != nil {
			return err
		}
		_, err = colab.NewRuntime(ctx, "runtime", &colab.RuntimeArgs{
			Name:     pulumi.String("colab-runtime"),
			Location: pulumi.String("us-central1"),
			NotebookRuntimeTemplateRef: &colab.RuntimeNotebookRuntimeTemplateRefArgs{
				NotebookRuntimeTemplate: myTemplate.ID(),
			},
			DisplayName:  pulumi.String("Runtime full"),
			RuntimeUser:  pulumi.String("gterraformtestuser@gmail.com"),
			Description:  pulumi.String("Full runtime"),
			DesiredState: pulumi.String("ACTIVE"),
			AutoUpgrade:  pulumi.Bool(true),
		}, pulumi.DependsOn([]pulumi.Resource{
			myTemplate,
		}))
		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 myTemplate = new Gcp.Colab.RuntimeTemplate("my_template", new()
    {
        Name = "colab-runtime",
        DisplayName = "Runtime template full",
        Location = "us-central1",
        Description = "Full runtime template",
        MachineSpec = new Gcp.Colab.Inputs.RuntimeTemplateMachineSpecArgs
        {
            MachineType = "n1-standard-2",
            AcceleratorType = "NVIDIA_TESLA_T4",
            AcceleratorCount = 1,
        },
        DataPersistentDiskSpec = new Gcp.Colab.Inputs.RuntimeTemplateDataPersistentDiskSpecArgs
        {
            DiskType = "pd-standard",
            DiskSizeGb = "200",
        },
        NetworkSpec = new Gcp.Colab.Inputs.RuntimeTemplateNetworkSpecArgs
        {
            EnableInternetAccess = true,
        },
        Labels = 
        {
            { "k", "val" },
        },
        IdleShutdownConfig = new Gcp.Colab.Inputs.RuntimeTemplateIdleShutdownConfigArgs
        {
            IdleTimeout = "3600s",
        },
        EucConfig = new Gcp.Colab.Inputs.RuntimeTemplateEucConfigArgs
        {
            EucDisabled = true,
        },
        ShieldedVmConfig = new Gcp.Colab.Inputs.RuntimeTemplateShieldedVmConfigArgs
        {
            EnableSecureBoot = true,
        },
        NetworkTags = new[]
        {
            "abc",
            "def",
        },
        EncryptionSpec = new Gcp.Colab.Inputs.RuntimeTemplateEncryptionSpecArgs
        {
            KmsKeyName = "my-crypto-key",
        },
    });

    var runtime = new Gcp.Colab.Runtime("runtime", new()
    {
        Name = "colab-runtime",
        Location = "us-central1",
        NotebookRuntimeTemplateRef = new Gcp.Colab.Inputs.RuntimeNotebookRuntimeTemplateRefArgs
        {
            NotebookRuntimeTemplate = myTemplate.Id,
        },
        DisplayName = "Runtime full",
        RuntimeUser = "gterraformtestuser@gmail.com",
        Description = "Full runtime",
        DesiredState = "ACTIVE",
        AutoUpgrade = true,
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            myTemplate,
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.colab.RuntimeTemplate;
import com.pulumi.gcp.colab.RuntimeTemplateArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateMachineSpecArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateDataPersistentDiskSpecArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateNetworkSpecArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateIdleShutdownConfigArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateEucConfigArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateShieldedVmConfigArgs;
import com.pulumi.gcp.colab.inputs.RuntimeTemplateEncryptionSpecArgs;
import com.pulumi.gcp.colab.Runtime;
import com.pulumi.gcp.colab.RuntimeArgs;
import com.pulumi.gcp.colab.inputs.RuntimeNotebookRuntimeTemplateRefArgs;
import com.pulumi.resources.CustomResourceOptions;
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 myTemplate = new RuntimeTemplate("myTemplate", RuntimeTemplateArgs.builder()
            .name("colab-runtime")
            .displayName("Runtime template full")
            .location("us-central1")
            .description("Full runtime template")
            .machineSpec(RuntimeTemplateMachineSpecArgs.builder()
                .machineType("n1-standard-2")
                .acceleratorType("NVIDIA_TESLA_T4")
                .acceleratorCount(1)
                .build())
            .dataPersistentDiskSpec(RuntimeTemplateDataPersistentDiskSpecArgs.builder()
                .diskType("pd-standard")
                .diskSizeGb("200")
                .build())
            .networkSpec(RuntimeTemplateNetworkSpecArgs.builder()
                .enableInternetAccess(true)
                .build())
            .labels(Map.of("k", "val"))
            .idleShutdownConfig(RuntimeTemplateIdleShutdownConfigArgs.builder()
                .idleTimeout("3600s")
                .build())
            .eucConfig(RuntimeTemplateEucConfigArgs.builder()
                .eucDisabled(true)
                .build())
            .shieldedVmConfig(RuntimeTemplateShieldedVmConfigArgs.builder()
                .enableSecureBoot(true)
                .build())
            .networkTags(            
                "abc",
                "def")
            .encryptionSpec(RuntimeTemplateEncryptionSpecArgs.builder()
                .kmsKeyName("my-crypto-key")
                .build())
            .build());

        var runtime = new Runtime("runtime", RuntimeArgs.builder()
            .name("colab-runtime")
            .location("us-central1")
            .notebookRuntimeTemplateRef(RuntimeNotebookRuntimeTemplateRefArgs.builder()
                .notebookRuntimeTemplate(myTemplate.id())
                .build())
            .displayName("Runtime full")
            .runtimeUser("gterraformtestuser@gmail.com")
            .description("Full runtime")
            .desiredState("ACTIVE")
            .autoUpgrade(true)
            .build(), CustomResourceOptions.builder()
                .dependsOn(myTemplate)
                .build());

    }
}
resources:
  myTemplate:
    type: gcp:colab:RuntimeTemplate
    name: my_template
    properties:
      name: colab-runtime
      displayName: Runtime template full
      location: us-central1
      description: Full runtime template
      machineSpec:
        machineType: n1-standard-2
        acceleratorType: NVIDIA_TESLA_T4
        acceleratorCount: '1'
      dataPersistentDiskSpec:
        diskType: pd-standard
        diskSizeGb: 200
      networkSpec:
        enableInternetAccess: true
      labels:
        k: val
      idleShutdownConfig:
        idleTimeout: 3600s
      eucConfig:
        eucDisabled: true
      shieldedVmConfig:
        enableSecureBoot: true
      networkTags:
        - abc
        - def
      encryptionSpec:
        kmsKeyName: my-crypto-key
  runtime:
    type: gcp:colab:Runtime
    properties:
      name: colab-runtime
      location: us-central1
      notebookRuntimeTemplateRef:
        notebookRuntimeTemplate: ${myTemplate.id}
      displayName: Runtime full
      runtimeUser: gterraformtestuser@gmail.com
      description: Full runtime
      desiredState: ACTIVE
      autoUpgrade: true
    options:
      dependsOn:
        - ${myTemplate}

The autoUpgrade property triggers upgrades whenever the runtime starts, keeping it current with the latest patches. The description property adds organizational metadata. The desiredState property explicitly sets the runtime to ACTIVE (equivalent to RUNNING).

Beyond these examples

These snippets focus on specific runtime-level features: template-based provisioning, state management, and automatic upgrades. They’re intentionally minimal rather than full notebook environments.

The examples reference pre-existing infrastructure such as RuntimeTemplate resources with machine specs and network configuration, and user email addresses for runtime ownership. They focus on configuring the runtime rather than provisioning templates or managing access.

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

  • Template configuration (machine type, GPU, encryption, network settings)
  • Runtime lifecycle operations (start, stop, upgrade triggers)
  • Access control and IAM permissions
  • Integration with notebook files and storage

These omissions are intentional: the goal is to illustrate how each runtime feature is wired, not provide drop-in notebook modules. See the Colab Runtime resource reference for all available configuration options.

Let's create GCP Colab Notebook Runtimes

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Configuration & Setup
What's required to create a Colab runtime?
You need five required fields: name, location, notebookRuntimeTemplateRef (linking to a template), displayName, and runtimeUser.
Why does my runtime depend on a RuntimeTemplate?
Runtimes require an existing RuntimeTemplate to define machine specs and network configuration. All examples show dependsOn: [myTemplate] to ensure the template exists first.
What properties can't be changed after creating a runtime?
These properties are immutable: displayName, location, name, project, runtimeUser, and description. You’ll need to recreate the runtime to change them.
State Management
How do I stop or start a runtime?
Set desiredState to STOPPED to stop the runtime or RUNNING to start it.
What's the difference between desiredState and state?
desiredState is your input (what you want: RUNNING or STOPPED), while state is an output showing the runtime’s actual current state.
What does autoUpgrade do?
Setting autoUpgrade to true triggers an upgrade whenever the runtime starts, if an upgrade is available.

Using a different cloud?

Explore compute guides for other cloud providers: