The gcp:colab/runtime:Runtime resource, part of the Pulumi GCP provider, provisions a Google-managed VM that executes notebook code, referencing a RuntimeTemplate for infrastructure configuration. This guide focuses on three capabilities: template-based runtime creation, state control, and automatic upgrade configuration.
Runtimes depend on RuntimeTemplate resources that define machine specs, networking, and security settings. The examples are intentionally small. Combine them with your own templates and user management.
Create a runtime from a template
Most deployments reference a RuntimeTemplate that defines VM configuration, then create a runtime instance for a specific user.
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 machine type, networking, and other infrastructure details. The runtimeUser property assigns the runtime to a specific user email. Without desiredState specified, the runtime starts in ACTIVE state by default.
Control runtime state at creation
Runtimes can be created in a stopped state to avoid immediate compute costs while preserving configuration.
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}
Setting desiredState to STOPPED creates the runtime without starting the VM. This lets you provision infrastructure ahead of time and start it only when needed. The runtime retains all template-defined configuration while stopped.
Configure runtime lifecycle and upgrades
Production runtimes often need automatic upgrades and explicit state management to balance availability with cost control.
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, ensuring you run the latest version. Setting desiredState to ACTIVE explicitly starts the runtime at creation. The description property adds metadata for tracking and organization.
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 networking, and user email addresses for runtime access. They focus on configuring the runtime rather than defining the underlying VM specifications.
To keep things focused, common runtime patterns are omitted, including:
- Template configuration (machine type, GPU, networking, encryption)
- Runtime monitoring and health checks
- Cost optimization strategies
- Multi-user access patterns
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 FREEFrequently Asked Questions
Configuration & Setup
gcp.colab.RuntimeTemplate first, then reference it in the runtime’s notebookRuntimeTemplateRef property using the template’s ID. Use dependsOn to ensure the template is created before the runtime.displayName, location, name, project, runtimeUser, and description. Changing any of these requires replacing the runtime.runtimeUser specifies the user email who owns the runtime. It’s required and immutable, so it must be set correctly during creation.Runtime State Management
desiredState to RUNNING to start the runtime or STOPPED to stop it. This property can be changed after creation to control runtime state.state is a computed output showing the current runtime state, while desiredState is an input you set to control whether the runtime should be running or stopped.autoUpgrade to true. This triggers an upgrade whenever the runtime starts, if an upgrade is available.