The gcp:colab/schedule:Schedule resource, part of the Pulumi GCP provider, defines recurring execution schedules for Colab Enterprise notebooks: when they run, where notebooks are sourced, and how execution is controlled. This guide focuses on three capabilities: cron-based scheduling with Cloud Storage notebooks, schedule state management, and lifecycle controls.
Schedules depend on runtime templates for compute configuration, service accounts for execution permissions, and notebook sources in Cloud Storage or Dataform repositories. The examples are intentionally small. Combine them with your own runtime templates, IAM configuration, and notebook storage.
Schedule recurring notebook execution from Cloud Storage
Data teams run Jupyter notebooks on regular schedules for ETL pipelines, model training, or reporting workflows. Colab Enterprise schedules execute notebooks stored in Cloud Storage at specified intervals.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const myRuntimeTemplate = new gcp.colab.RuntimeTemplate("my_runtime_template", {
name: "runtime-template",
displayName: "Runtime template",
location: "us-central1",
machineSpec: {
machineType: "e2-standard-4",
},
networkSpec: {
enableInternetAccess: true,
},
});
const outputBucket = new gcp.storage.Bucket("output_bucket", {
name: "my_bucket",
location: "US",
forceDestroy: true,
uniformBucketLevelAccess: true,
});
const notebook = new gcp.storage.BucketObject("notebook", {
name: "hello_world.ipynb",
bucket: outputBucket.name,
content: ` {
\\"cells\\": [
{
\\"cell_type\\": \\"code\\",
\\"execution_count\\": null,
\\"metadata\\": {},
\\"outputs\\": [],
\\"source\\": [
\\"print(\\\\\\"Hello, World!\\\\\\")\\"
]
}
],
\\"metadata\\": {
\\"kernelspec\\": {
\\"display_name\\": \\"Python 3\\",
\\"language\\": \\"python\\",
\\"name\\": \\"python3\\"
},
\\"language_info\\": {
\\"codemirror_mode\\": {
\\"name\\": \\"ipython\\",
\\"version\\": 3
},
\\"file_extension\\": \\".py\\",
\\"mimetype\\": \\"text/x-python\\",
\\"name\\": \\"python\\",
\\"nbconvert_exporter\\": \\"python\\",
\\"pygments_lexer\\": \\"ipython3\\",
\\"version\\": \\"3.8.5\\"
}
},
\\"nbformat\\": 4,
\\"nbformat_minor\\": 4
}
`,
});
const schedule = new gcp.colab.Schedule("schedule", {
displayName: "basic-schedule",
location: "us-west1",
maxConcurrentRunCount: "2",
cron: "TZ=America/Los_Angeles * * * * *",
createNotebookExecutionJobRequest: {
notebookExecutionJob: {
displayName: "Notebook execution",
gcsNotebookSource: {
uri: pulumi.interpolate`gs://${notebook.bucket}/${notebook.name}`,
generation: notebook.generation,
},
notebookRuntimeTemplateResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}`,
gcsOutputUri: pulumi.interpolate`gs://${outputBucket.name}`,
serviceAccount: "my@service-account.com",
},
},
}, {
dependsOn: [
myRuntimeTemplate,
outputBucket,
],
});
import pulumi
import pulumi_gcp as gcp
my_runtime_template = gcp.colab.RuntimeTemplate("my_runtime_template",
name="runtime-template",
display_name="Runtime template",
location="us-central1",
machine_spec={
"machine_type": "e2-standard-4",
},
network_spec={
"enable_internet_access": True,
})
output_bucket = gcp.storage.Bucket("output_bucket",
name="my_bucket",
location="US",
force_destroy=True,
uniform_bucket_level_access=True)
notebook = gcp.storage.BucketObject("notebook",
name="hello_world.ipynb",
bucket=output_bucket.name,
content=""" {
\"cells\": [
{
\"cell_type\": \"code\",
\"execution_count\": null,
\"metadata\": {},
\"outputs\": [],
\"source\": [
\"print(\\\"Hello, World!\\\")\"
]
}
],
\"metadata\": {
\"kernelspec\": {
\"display_name\": \"Python 3\",
\"language\": \"python\",
\"name\": \"python3\"
},
\"language_info\": {
\"codemirror_mode\": {
\"name\": \"ipython\",
\"version\": 3
},
\"file_extension\": \".py\",
\"mimetype\": \"text/x-python\",
\"name\": \"python\",
\"nbconvert_exporter\": \"python\",
\"pygments_lexer\": \"ipython3\",
\"version\": \"3.8.5\"
}
},
\"nbformat\": 4,
\"nbformat_minor\": 4
}
""")
schedule = gcp.colab.Schedule("schedule",
display_name="basic-schedule",
location="us-west1",
max_concurrent_run_count="2",
cron="TZ=America/Los_Angeles * * * * *",
create_notebook_execution_job_request={
"notebook_execution_job": {
"display_name": "Notebook execution",
"gcs_notebook_source": {
"uri": pulumi.Output.all(
bucket=notebook.bucket,
name=notebook.name
).apply(lambda resolved_outputs: f"gs://{resolved_outputs['bucket']}/{resolved_outputs['name']}")
,
"generation": notebook.generation,
},
"notebook_runtime_template_resource_name": pulumi.Output.all(
project=my_runtime_template.project,
location=my_runtime_template.location,
name=my_runtime_template.name
).apply(lambda resolved_outputs: f"projects/{resolved_outputs['project']}/locations/{resolved_outputs['location']}/notebookRuntimeTemplates/{resolved_outputs['name']}")
,
"gcs_output_uri": output_bucket.name.apply(lambda name: f"gs://{name}"),
"service_account": "my@service-account.com",
},
},
opts = pulumi.ResourceOptions(depends_on=[
my_runtime_template,
output_bucket,
]))
package main
import (
"fmt"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/colab"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
myRuntimeTemplate, err := colab.NewRuntimeTemplate(ctx, "my_runtime_template", &colab.RuntimeTemplateArgs{
Name: pulumi.String("runtime-template"),
DisplayName: pulumi.String("Runtime template"),
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
}
outputBucket, err := storage.NewBucket(ctx, "output_bucket", &storage.BucketArgs{
Name: pulumi.String("my_bucket"),
Location: pulumi.String("US"),
ForceDestroy: pulumi.Bool(true),
UniformBucketLevelAccess: pulumi.Bool(true),
})
if err != nil {
return err
}
notebook, err := storage.NewBucketObject(ctx, "notebook", &storage.BucketObjectArgs{
Name: pulumi.String("hello_world.ipynb"),
Bucket: outputBucket.Name,
Content: pulumi.String(` {
\"cells\": [
{
\"cell_type\": \"code\",
\"execution_count\": null,
\"metadata\": {},
\"outputs\": [],
\"source\": [
\"print(\\\"Hello, World!\\\")\"
]
}
],
\"metadata\": {
\"kernelspec\": {
\"display_name\": \"Python 3\",
\"language\": \"python\",
\"name\": \"python3\"
},
\"language_info\": {
\"codemirror_mode\": {
\"name\": \"ipython\",
\"version\": 3
},
\"file_extension\": \".py\",
\"mimetype\": \"text/x-python\",
\"name\": \"python\",
\"nbconvert_exporter\": \"python\",
\"pygments_lexer\": \"ipython3\",
\"version\": \"3.8.5\"
}
},
\"nbformat\": 4,
\"nbformat_minor\": 4
}
`),
})
if err != nil {
return err
}
_, err = colab.NewSchedule(ctx, "schedule", &colab.ScheduleArgs{
DisplayName: pulumi.String("basic-schedule"),
Location: pulumi.String("us-west1"),
MaxConcurrentRunCount: pulumi.String("2"),
Cron: pulumi.String("TZ=America/Los_Angeles * * * * *"),
CreateNotebookExecutionJobRequest: &colab.ScheduleCreateNotebookExecutionJobRequestArgs{
NotebookExecutionJob: &colab.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs{
DisplayName: pulumi.String("Notebook execution"),
GcsNotebookSource: &colab.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobGcsNotebookSourceArgs{
Uri: pulumi.All(notebook.Bucket, notebook.Name).ApplyT(func(_args []interface{}) (string, error) {
bucket := _args[0].(string)
name := _args[1].(string)
return fmt.Sprintf("gs://%v/%v", bucket, name), nil
}).(pulumi.StringOutput),
Generation: notebook.Generation,
},
NotebookRuntimeTemplateResourceName: pulumi.All(myRuntimeTemplate.Project, myRuntimeTemplate.Location, myRuntimeTemplate.Name).ApplyT(func(_args []interface{}) (string, error) {
project := _args[0].(string)
location := _args[1].(string)
name := _args[2].(string)
return fmt.Sprintf("projects/%v/locations/%v/notebookRuntimeTemplates/%v", project, location, name), nil
}).(pulumi.StringOutput),
GcsOutputUri: outputBucket.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("gs://%v", name), nil
}).(pulumi.StringOutput),
ServiceAccount: pulumi.String("my@service-account.com"),
},
},
}, pulumi.DependsOn([]pulumi.Resource{
myRuntimeTemplate,
outputBucket,
}))
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 myRuntimeTemplate = new Gcp.Colab.RuntimeTemplate("my_runtime_template", new()
{
Name = "runtime-template",
DisplayName = "Runtime template",
Location = "us-central1",
MachineSpec = new Gcp.Colab.Inputs.RuntimeTemplateMachineSpecArgs
{
MachineType = "e2-standard-4",
},
NetworkSpec = new Gcp.Colab.Inputs.RuntimeTemplateNetworkSpecArgs
{
EnableInternetAccess = true,
},
});
var outputBucket = new Gcp.Storage.Bucket("output_bucket", new()
{
Name = "my_bucket",
Location = "US",
ForceDestroy = true,
UniformBucketLevelAccess = true,
});
var notebook = new Gcp.Storage.BucketObject("notebook", new()
{
Name = "hello_world.ipynb",
Bucket = outputBucket.Name,
Content = @" {
\""cells\"": [
{
\""cell_type\"": \""code\"",
\""execution_count\"": null,
\""metadata\"": {},
\""outputs\"": [],
\""source\"": [
\""print(\\\""Hello, World!\\\"")\""
]
}
],
\""metadata\"": {
\""kernelspec\"": {
\""display_name\"": \""Python 3\"",
\""language\"": \""python\"",
\""name\"": \""python3\""
},
\""language_info\"": {
\""codemirror_mode\"": {
\""name\"": \""ipython\"",
\""version\"": 3
},
\""file_extension\"": \"".py\"",
\""mimetype\"": \""text/x-python\"",
\""name\"": \""python\"",
\""nbconvert_exporter\"": \""python\"",
\""pygments_lexer\"": \""ipython3\"",
\""version\"": \""3.8.5\""
}
},
\""nbformat\"": 4,
\""nbformat_minor\"": 4
}
",
});
var schedule = new Gcp.Colab.Schedule("schedule", new()
{
DisplayName = "basic-schedule",
Location = "us-west1",
MaxConcurrentRunCount = "2",
Cron = "TZ=America/Los_Angeles * * * * *",
CreateNotebookExecutionJobRequest = new Gcp.Colab.Inputs.ScheduleCreateNotebookExecutionJobRequestArgs
{
NotebookExecutionJob = new Gcp.Colab.Inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs
{
DisplayName = "Notebook execution",
GcsNotebookSource = new Gcp.Colab.Inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobGcsNotebookSourceArgs
{
Uri = Output.Tuple(notebook.Bucket, notebook.Name).Apply(values =>
{
var bucket = values.Item1;
var name = values.Item2;
return $"gs://{bucket}/{name}";
}),
Generation = notebook.Generation,
},
NotebookRuntimeTemplateResourceName = Output.Tuple(myRuntimeTemplate.Project, myRuntimeTemplate.Location, myRuntimeTemplate.Name).Apply(values =>
{
var project = values.Item1;
var location = values.Item2;
var name = values.Item3;
return $"projects/{project}/locations/{location}/notebookRuntimeTemplates/{name}";
}),
GcsOutputUri = outputBucket.Name.Apply(name => $"gs://{name}"),
ServiceAccount = "my@service-account.com",
},
},
}, new CustomResourceOptions
{
DependsOn =
{
myRuntimeTemplate,
outputBucket,
},
});
});
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.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.BucketObject;
import com.pulumi.gcp.storage.BucketObjectArgs;
import com.pulumi.gcp.colab.Schedule;
import com.pulumi.gcp.colab.ScheduleArgs;
import com.pulumi.gcp.colab.inputs.ScheduleCreateNotebookExecutionJobRequestArgs;
import com.pulumi.gcp.colab.inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs;
import com.pulumi.gcp.colab.inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobGcsNotebookSourceArgs;
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 myRuntimeTemplate = new RuntimeTemplate("myRuntimeTemplate", RuntimeTemplateArgs.builder()
.name("runtime-template")
.displayName("Runtime template")
.location("us-central1")
.machineSpec(RuntimeTemplateMachineSpecArgs.builder()
.machineType("e2-standard-4")
.build())
.networkSpec(RuntimeTemplateNetworkSpecArgs.builder()
.enableInternetAccess(true)
.build())
.build());
var outputBucket = new Bucket("outputBucket", BucketArgs.builder()
.name("my_bucket")
.location("US")
.forceDestroy(true)
.uniformBucketLevelAccess(true)
.build());
var notebook = new BucketObject("notebook", BucketObjectArgs.builder()
.name("hello_world.ipynb")
.bucket(outputBucket.name())
.content("""
{
\"cells\": [
{
\"cell_type\": \"code\",
\"execution_count\": null,
\"metadata\": {},
\"outputs\": [],
\"source\": [
\"print(\\\"Hello, World!\\\")\"
]
}
],
\"metadata\": {
\"kernelspec\": {
\"display_name\": \"Python 3\",
\"language\": \"python\",
\"name\": \"python3\"
},
\"language_info\": {
\"codemirror_mode\": {
\"name\": \"ipython\",
\"version\": 3
},
\"file_extension\": \".py\",
\"mimetype\": \"text/x-python\",
\"name\": \"python\",
\"nbconvert_exporter\": \"python\",
\"pygments_lexer\": \"ipython3\",
\"version\": \"3.8.5\"
}
},
\"nbformat\": 4,
\"nbformat_minor\": 4
}
""")
.build());
var schedule = new Schedule("schedule", ScheduleArgs.builder()
.displayName("basic-schedule")
.location("us-west1")
.maxConcurrentRunCount("2")
.cron("TZ=America/Los_Angeles * * * * *")
.createNotebookExecutionJobRequest(ScheduleCreateNotebookExecutionJobRequestArgs.builder()
.notebookExecutionJob(ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs.builder()
.displayName("Notebook execution")
.gcsNotebookSource(ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobGcsNotebookSourceArgs.builder()
.uri(Output.tuple(notebook.bucket(), notebook.name()).applyValue(values -> {
var bucket = values.t1;
var name = values.t2;
return String.format("gs://%s/%s", bucket,name);
}))
.generation(notebook.generation())
.build())
.notebookRuntimeTemplateResourceName(Output.tuple(myRuntimeTemplate.project(), myRuntimeTemplate.location(), myRuntimeTemplate.name()).applyValue(values -> {
var project = values.t1;
var location = values.t2;
var name = values.t3;
return String.format("projects/%s/locations/%s/notebookRuntimeTemplates/%s", project,location,name);
}))
.gcsOutputUri(outputBucket.name().applyValue(_name -> String.format("gs://%s", _name)))
.serviceAccount("my@service-account.com")
.build())
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(
myRuntimeTemplate,
outputBucket)
.build());
}
}
resources:
myRuntimeTemplate:
type: gcp:colab:RuntimeTemplate
name: my_runtime_template
properties:
name: runtime-template
displayName: Runtime template
location: us-central1
machineSpec:
machineType: e2-standard-4
networkSpec:
enableInternetAccess: true
outputBucket:
type: gcp:storage:Bucket
name: output_bucket
properties:
name: my_bucket
location: US
forceDestroy: true
uniformBucketLevelAccess: true
notebook:
type: gcp:storage:BucketObject
properties:
name: hello_world.ipynb
bucket: ${outputBucket.name}
content: |2
{
\"cells\": [
{
\"cell_type\": \"code\",
\"execution_count\": null,
\"metadata\": {},
\"outputs\": [],
\"source\": [
\"print(\\\"Hello, World!\\\")\"
]
}
],
\"metadata\": {
\"kernelspec\": {
\"display_name\": \"Python 3\",
\"language\": \"python\",
\"name\": \"python3\"
},
\"language_info\": {
\"codemirror_mode\": {
\"name\": \"ipython\",
\"version\": 3
},
\"file_extension\": \".py\",
\"mimetype\": \"text/x-python\",
\"name\": \"python\",
\"nbconvert_exporter\": \"python\",
\"pygments_lexer\": \"ipython3\",
\"version\": \"3.8.5\"
}
},
\"nbformat\": 4,
\"nbformat_minor\": 4
}
schedule:
type: gcp:colab:Schedule
properties:
displayName: basic-schedule
location: us-west1
maxConcurrentRunCount: 2
cron: TZ=America/Los_Angeles * * * * *
createNotebookExecutionJobRequest:
notebookExecutionJob:
displayName: Notebook execution
gcsNotebookSource:
uri: gs://${notebook.bucket}/${notebook.name}
generation: ${notebook.generation}
notebookRuntimeTemplateResourceName: projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}
gcsOutputUri: gs://${outputBucket.name}
serviceAccount: my@service-account.com
options:
dependsOn:
- ${myRuntimeTemplate}
- ${outputBucket}
The cron property defines when executions trigger, using standard cron syntax with timezone specification (here, every minute in Pacific time). The gcsNotebookSource points to a notebook in Cloud Storage by URI and generation. The notebookRuntimeTemplateResourceName specifies the compute environment (machine type, network access). Results write to gcsOutputUri. The maxConcurrentRunCount limits how many executions can run simultaneously; additional triggers are skipped by default.
Create a paused schedule for manual activation
When building new pipelines, teams often define schedules without immediately starting execution, allowing time for testing before activation.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const myRuntimeTemplate = new gcp.colab.RuntimeTemplate("my_runtime_template", {
name: "runtime-template",
displayName: "Runtime template",
location: "us-central1",
machineSpec: {
machineType: "e2-standard-4",
},
networkSpec: {
enableInternetAccess: true,
},
});
const outputBucket = new gcp.storage.Bucket("output_bucket", {
name: "my_bucket",
location: "US",
forceDestroy: true,
uniformBucketLevelAccess: true,
});
const notebook = new gcp.storage.BucketObject("notebook", {
name: "hello_world.ipynb",
bucket: outputBucket.name,
content: ` {
\\"cells\\": [
{
\\"cell_type\\": \\"code\\",
\\"execution_count\\": null,
\\"metadata\\": {},
\\"outputs\\": [],
\\"source\\": [
\\"print(\\\\\\"Hello, World!\\\\\\")\\"
]
}
],
\\"metadata\\": {
\\"kernelspec\\": {
\\"display_name\\": \\"Python 3\\",
\\"language\\": \\"python\\",
\\"name\\": \\"python3\\"
},
\\"language_info\\": {
\\"codemirror_mode\\": {
\\"name\\": \\"ipython\\",
\\"version\\": 3
},
\\"file_extension\\": \\".py\\",
\\"mimetype\\": \\"text/x-python\\",
\\"name\\": \\"python\\",
\\"nbconvert_exporter\\": \\"python\\",
\\"pygments_lexer\\": \\"ipython3\\",
\\"version\\": \\"3.8.5\\"
}
},
\\"nbformat\\": 4,
\\"nbformat_minor\\": 4
}
`,
});
const schedule = new gcp.colab.Schedule("schedule", {
displayName: "paused-schedule",
location: "us-west1",
maxConcurrentRunCount: "2",
cron: "TZ=America/Los_Angeles * * * * *",
desiredState: "PAUSED",
createNotebookExecutionJobRequest: {
notebookExecutionJob: {
displayName: "Notebook execution",
gcsNotebookSource: {
uri: pulumi.interpolate`gs://${notebook.bucket}/${notebook.name}`,
generation: notebook.generation,
},
notebookRuntimeTemplateResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}`,
gcsOutputUri: pulumi.interpolate`gs://${outputBucket.name}`,
serviceAccount: "my@service-account.com",
},
},
}, {
dependsOn: [
myRuntimeTemplate,
outputBucket,
],
});
import pulumi
import pulumi_gcp as gcp
my_runtime_template = gcp.colab.RuntimeTemplate("my_runtime_template",
name="runtime-template",
display_name="Runtime template",
location="us-central1",
machine_spec={
"machine_type": "e2-standard-4",
},
network_spec={
"enable_internet_access": True,
})
output_bucket = gcp.storage.Bucket("output_bucket",
name="my_bucket",
location="US",
force_destroy=True,
uniform_bucket_level_access=True)
notebook = gcp.storage.BucketObject("notebook",
name="hello_world.ipynb",
bucket=output_bucket.name,
content=""" {
\"cells\": [
{
\"cell_type\": \"code\",
\"execution_count\": null,
\"metadata\": {},
\"outputs\": [],
\"source\": [
\"print(\\\"Hello, World!\\\")\"
]
}
],
\"metadata\": {
\"kernelspec\": {
\"display_name\": \"Python 3\",
\"language\": \"python\",
\"name\": \"python3\"
},
\"language_info\": {
\"codemirror_mode\": {
\"name\": \"ipython\",
\"version\": 3
},
\"file_extension\": \".py\",
\"mimetype\": \"text/x-python\",
\"name\": \"python\",
\"nbconvert_exporter\": \"python\",
\"pygments_lexer\": \"ipython3\",
\"version\": \"3.8.5\"
}
},
\"nbformat\": 4,
\"nbformat_minor\": 4
}
""")
schedule = gcp.colab.Schedule("schedule",
display_name="paused-schedule",
location="us-west1",
max_concurrent_run_count="2",
cron="TZ=America/Los_Angeles * * * * *",
desired_state="PAUSED",
create_notebook_execution_job_request={
"notebook_execution_job": {
"display_name": "Notebook execution",
"gcs_notebook_source": {
"uri": pulumi.Output.all(
bucket=notebook.bucket,
name=notebook.name
).apply(lambda resolved_outputs: f"gs://{resolved_outputs['bucket']}/{resolved_outputs['name']}")
,
"generation": notebook.generation,
},
"notebook_runtime_template_resource_name": pulumi.Output.all(
project=my_runtime_template.project,
location=my_runtime_template.location,
name=my_runtime_template.name
).apply(lambda resolved_outputs: f"projects/{resolved_outputs['project']}/locations/{resolved_outputs['location']}/notebookRuntimeTemplates/{resolved_outputs['name']}")
,
"gcs_output_uri": output_bucket.name.apply(lambda name: f"gs://{name}"),
"service_account": "my@service-account.com",
},
},
opts = pulumi.ResourceOptions(depends_on=[
my_runtime_template,
output_bucket,
]))
package main
import (
"fmt"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/colab"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
myRuntimeTemplate, err := colab.NewRuntimeTemplate(ctx, "my_runtime_template", &colab.RuntimeTemplateArgs{
Name: pulumi.String("runtime-template"),
DisplayName: pulumi.String("Runtime template"),
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
}
outputBucket, err := storage.NewBucket(ctx, "output_bucket", &storage.BucketArgs{
Name: pulumi.String("my_bucket"),
Location: pulumi.String("US"),
ForceDestroy: pulumi.Bool(true),
UniformBucketLevelAccess: pulumi.Bool(true),
})
if err != nil {
return err
}
notebook, err := storage.NewBucketObject(ctx, "notebook", &storage.BucketObjectArgs{
Name: pulumi.String("hello_world.ipynb"),
Bucket: outputBucket.Name,
Content: pulumi.String(` {
\"cells\": [
{
\"cell_type\": \"code\",
\"execution_count\": null,
\"metadata\": {},
\"outputs\": [],
\"source\": [
\"print(\\\"Hello, World!\\\")\"
]
}
],
\"metadata\": {
\"kernelspec\": {
\"display_name\": \"Python 3\",
\"language\": \"python\",
\"name\": \"python3\"
},
\"language_info\": {
\"codemirror_mode\": {
\"name\": \"ipython\",
\"version\": 3
},
\"file_extension\": \".py\",
\"mimetype\": \"text/x-python\",
\"name\": \"python\",
\"nbconvert_exporter\": \"python\",
\"pygments_lexer\": \"ipython3\",
\"version\": \"3.8.5\"
}
},
\"nbformat\": 4,
\"nbformat_minor\": 4
}
`),
})
if err != nil {
return err
}
_, err = colab.NewSchedule(ctx, "schedule", &colab.ScheduleArgs{
DisplayName: pulumi.String("paused-schedule"),
Location: pulumi.String("us-west1"),
MaxConcurrentRunCount: pulumi.String("2"),
Cron: pulumi.String("TZ=America/Los_Angeles * * * * *"),
DesiredState: pulumi.String("PAUSED"),
CreateNotebookExecutionJobRequest: &colab.ScheduleCreateNotebookExecutionJobRequestArgs{
NotebookExecutionJob: &colab.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs{
DisplayName: pulumi.String("Notebook execution"),
GcsNotebookSource: &colab.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobGcsNotebookSourceArgs{
Uri: pulumi.All(notebook.Bucket, notebook.Name).ApplyT(func(_args []interface{}) (string, error) {
bucket := _args[0].(string)
name := _args[1].(string)
return fmt.Sprintf("gs://%v/%v", bucket, name), nil
}).(pulumi.StringOutput),
Generation: notebook.Generation,
},
NotebookRuntimeTemplateResourceName: pulumi.All(myRuntimeTemplate.Project, myRuntimeTemplate.Location, myRuntimeTemplate.Name).ApplyT(func(_args []interface{}) (string, error) {
project := _args[0].(string)
location := _args[1].(string)
name := _args[2].(string)
return fmt.Sprintf("projects/%v/locations/%v/notebookRuntimeTemplates/%v", project, location, name), nil
}).(pulumi.StringOutput),
GcsOutputUri: outputBucket.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("gs://%v", name), nil
}).(pulumi.StringOutput),
ServiceAccount: pulumi.String("my@service-account.com"),
},
},
}, pulumi.DependsOn([]pulumi.Resource{
myRuntimeTemplate,
outputBucket,
}))
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 myRuntimeTemplate = new Gcp.Colab.RuntimeTemplate("my_runtime_template", new()
{
Name = "runtime-template",
DisplayName = "Runtime template",
Location = "us-central1",
MachineSpec = new Gcp.Colab.Inputs.RuntimeTemplateMachineSpecArgs
{
MachineType = "e2-standard-4",
},
NetworkSpec = new Gcp.Colab.Inputs.RuntimeTemplateNetworkSpecArgs
{
EnableInternetAccess = true,
},
});
var outputBucket = new Gcp.Storage.Bucket("output_bucket", new()
{
Name = "my_bucket",
Location = "US",
ForceDestroy = true,
UniformBucketLevelAccess = true,
});
var notebook = new Gcp.Storage.BucketObject("notebook", new()
{
Name = "hello_world.ipynb",
Bucket = outputBucket.Name,
Content = @" {
\""cells\"": [
{
\""cell_type\"": \""code\"",
\""execution_count\"": null,
\""metadata\"": {},
\""outputs\"": [],
\""source\"": [
\""print(\\\""Hello, World!\\\"")\""
]
}
],
\""metadata\"": {
\""kernelspec\"": {
\""display_name\"": \""Python 3\"",
\""language\"": \""python\"",
\""name\"": \""python3\""
},
\""language_info\"": {
\""codemirror_mode\"": {
\""name\"": \""ipython\"",
\""version\"": 3
},
\""file_extension\"": \"".py\"",
\""mimetype\"": \""text/x-python\"",
\""name\"": \""python\"",
\""nbconvert_exporter\"": \""python\"",
\""pygments_lexer\"": \""ipython3\"",
\""version\"": \""3.8.5\""
}
},
\""nbformat\"": 4,
\""nbformat_minor\"": 4
}
",
});
var schedule = new Gcp.Colab.Schedule("schedule", new()
{
DisplayName = "paused-schedule",
Location = "us-west1",
MaxConcurrentRunCount = "2",
Cron = "TZ=America/Los_Angeles * * * * *",
DesiredState = "PAUSED",
CreateNotebookExecutionJobRequest = new Gcp.Colab.Inputs.ScheduleCreateNotebookExecutionJobRequestArgs
{
NotebookExecutionJob = new Gcp.Colab.Inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs
{
DisplayName = "Notebook execution",
GcsNotebookSource = new Gcp.Colab.Inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobGcsNotebookSourceArgs
{
Uri = Output.Tuple(notebook.Bucket, notebook.Name).Apply(values =>
{
var bucket = values.Item1;
var name = values.Item2;
return $"gs://{bucket}/{name}";
}),
Generation = notebook.Generation,
},
NotebookRuntimeTemplateResourceName = Output.Tuple(myRuntimeTemplate.Project, myRuntimeTemplate.Location, myRuntimeTemplate.Name).Apply(values =>
{
var project = values.Item1;
var location = values.Item2;
var name = values.Item3;
return $"projects/{project}/locations/{location}/notebookRuntimeTemplates/{name}";
}),
GcsOutputUri = outputBucket.Name.Apply(name => $"gs://{name}"),
ServiceAccount = "my@service-account.com",
},
},
}, new CustomResourceOptions
{
DependsOn =
{
myRuntimeTemplate,
outputBucket,
},
});
});
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.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.storage.BucketObject;
import com.pulumi.gcp.storage.BucketObjectArgs;
import com.pulumi.gcp.colab.Schedule;
import com.pulumi.gcp.colab.ScheduleArgs;
import com.pulumi.gcp.colab.inputs.ScheduleCreateNotebookExecutionJobRequestArgs;
import com.pulumi.gcp.colab.inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs;
import com.pulumi.gcp.colab.inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobGcsNotebookSourceArgs;
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 myRuntimeTemplate = new RuntimeTemplate("myRuntimeTemplate", RuntimeTemplateArgs.builder()
.name("runtime-template")
.displayName("Runtime template")
.location("us-central1")
.machineSpec(RuntimeTemplateMachineSpecArgs.builder()
.machineType("e2-standard-4")
.build())
.networkSpec(RuntimeTemplateNetworkSpecArgs.builder()
.enableInternetAccess(true)
.build())
.build());
var outputBucket = new Bucket("outputBucket", BucketArgs.builder()
.name("my_bucket")
.location("US")
.forceDestroy(true)
.uniformBucketLevelAccess(true)
.build());
var notebook = new BucketObject("notebook", BucketObjectArgs.builder()
.name("hello_world.ipynb")
.bucket(outputBucket.name())
.content("""
{
\"cells\": [
{
\"cell_type\": \"code\",
\"execution_count\": null,
\"metadata\": {},
\"outputs\": [],
\"source\": [
\"print(\\\"Hello, World!\\\")\"
]
}
],
\"metadata\": {
\"kernelspec\": {
\"display_name\": \"Python 3\",
\"language\": \"python\",
\"name\": \"python3\"
},
\"language_info\": {
\"codemirror_mode\": {
\"name\": \"ipython\",
\"version\": 3
},
\"file_extension\": \".py\",
\"mimetype\": \"text/x-python\",
\"name\": \"python\",
\"nbconvert_exporter\": \"python\",
\"pygments_lexer\": \"ipython3\",
\"version\": \"3.8.5\"
}
},
\"nbformat\": 4,
\"nbformat_minor\": 4
}
""")
.build());
var schedule = new Schedule("schedule", ScheduleArgs.builder()
.displayName("paused-schedule")
.location("us-west1")
.maxConcurrentRunCount("2")
.cron("TZ=America/Los_Angeles * * * * *")
.desiredState("PAUSED")
.createNotebookExecutionJobRequest(ScheduleCreateNotebookExecutionJobRequestArgs.builder()
.notebookExecutionJob(ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs.builder()
.displayName("Notebook execution")
.gcsNotebookSource(ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobGcsNotebookSourceArgs.builder()
.uri(Output.tuple(notebook.bucket(), notebook.name()).applyValue(values -> {
var bucket = values.t1;
var name = values.t2;
return String.format("gs://%s/%s", bucket,name);
}))
.generation(notebook.generation())
.build())
.notebookRuntimeTemplateResourceName(Output.tuple(myRuntimeTemplate.project(), myRuntimeTemplate.location(), myRuntimeTemplate.name()).applyValue(values -> {
var project = values.t1;
var location = values.t2;
var name = values.t3;
return String.format("projects/%s/locations/%s/notebookRuntimeTemplates/%s", project,location,name);
}))
.gcsOutputUri(outputBucket.name().applyValue(_name -> String.format("gs://%s", _name)))
.serviceAccount("my@service-account.com")
.build())
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(
myRuntimeTemplate,
outputBucket)
.build());
}
}
resources:
myRuntimeTemplate:
type: gcp:colab:RuntimeTemplate
name: my_runtime_template
properties:
name: runtime-template
displayName: Runtime template
location: us-central1
machineSpec:
machineType: e2-standard-4
networkSpec:
enableInternetAccess: true
outputBucket:
type: gcp:storage:Bucket
name: output_bucket
properties:
name: my_bucket
location: US
forceDestroy: true
uniformBucketLevelAccess: true
notebook:
type: gcp:storage:BucketObject
properties:
name: hello_world.ipynb
bucket: ${outputBucket.name}
content: |2
{
\"cells\": [
{
\"cell_type\": \"code\",
\"execution_count\": null,
\"metadata\": {},
\"outputs\": [],
\"source\": [
\"print(\\\"Hello, World!\\\")\"
]
}
],
\"metadata\": {
\"kernelspec\": {
\"display_name\": \"Python 3\",
\"language\": \"python\",
\"name\": \"python3\"
},
\"language_info\": {
\"codemirror_mode\": {
\"name\": \"ipython\",
\"version\": 3
},
\"file_extension\": \".py\",
\"mimetype\": \"text/x-python\",
\"name\": \"python\",
\"nbconvert_exporter\": \"python\",
\"pygments_lexer\": \"ipython3\",
\"version\": \"3.8.5\"
}
},
\"nbformat\": 4,
\"nbformat_minor\": 4
}
schedule:
type: gcp:colab:Schedule
properties:
displayName: paused-schedule
location: us-west1
maxConcurrentRunCount: 2
cron: TZ=America/Los_Angeles * * * * *
desiredState: PAUSED
createNotebookExecutionJobRequest:
notebookExecutionJob:
displayName: Notebook execution
gcsNotebookSource:
uri: gs://${notebook.bucket}/${notebook.name}
generation: ${notebook.generation}
notebookRuntimeTemplateResourceName: projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}
gcsOutputUri: gs://${outputBucket.name}
serviceAccount: my@service-account.com
options:
dependsOn:
- ${myRuntimeTemplate}
- ${outputBucket}
The desiredState property controls whether the schedule actively triggers runs. Set it to PAUSED to define the schedule without starting executions, then change to ACTIVE when ready. This lets you validate notebook logic and runtime configuration before the first scheduled run.
Control schedule lifecycle with time bounds and run limits
Production schedules need guardrails: maximum concurrent executions to prevent resource exhaustion, time windows for when runs are allowed, and total run counts for finite workflows.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const myRuntimeTemplate = new gcp.colab.RuntimeTemplate("my_runtime_template", {
name: "runtime-template",
displayName: "Runtime template",
location: "us-central1",
machineSpec: {
machineType: "e2-standard-4",
},
networkSpec: {
enableInternetAccess: true,
},
});
const outputBucket = new gcp.storage.Bucket("output_bucket", {
name: "my_bucket",
location: "US",
forceDestroy: true,
uniformBucketLevelAccess: true,
});
const secret = new gcp.secretmanager.Secret("secret", {
secretId: "secret",
replication: {
auto: {},
},
});
const secretVersion = new gcp.secretmanager.SecretVersion("secret_version", {
secret: secret.id,
secretData: "secret-data",
});
const dataformRepository = new gcp.dataform.Repository("dataform_repository", {
name: "dataform-repository",
displayName: "dataform_repository",
npmrcEnvironmentVariablesSecretVersion: secretVersion.id,
kmsKeyName: "my-key",
labels: {
label_foo1: "label-bar1",
},
gitRemoteSettings: {
url: "https://github.com/OWNER/REPOSITORY.git",
defaultBranch: "main",
authenticationTokenSecretVersion: secretVersion.id,
},
workspaceCompilationOverrides: {
defaultDatabase: "database",
schemaSuffix: "_suffix",
tablePrefix: "prefix_",
},
});
const schedule = new gcp.colab.Schedule("schedule", {
displayName: "full-schedule",
location: "us-west1",
allowQueueing: true,
maxConcurrentRunCount: "2",
cron: "TZ=America/Los_Angeles * * * * *",
maxRunCount: "5",
startTime: "2014-10-02T15:01:23Z",
endTime: "2014-10-10T15:01:23Z",
desiredState: "ACTIVE",
createNotebookExecutionJobRequest: {
notebookExecutionJob: {
displayName: "Notebook execution",
executionTimeout: "86400s",
dataformRepositorySource: {
commitSha: "randomsha123",
dataformRepositoryResourceName: pulumi.interpolate`projects/my-project-name/locations/us-west1/repositories/${dataformRepository.name}`,
},
notebookRuntimeTemplateResourceName: pulumi.interpolate`projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}`,
gcsOutputUri: pulumi.interpolate`gs://${outputBucket.name}`,
serviceAccount: "my@service-account.com",
},
},
}, {
dependsOn: [
myRuntimeTemplate,
outputBucket,
secretVersion,
dataformRepository,
],
});
import pulumi
import pulumi_gcp as gcp
my_runtime_template = gcp.colab.RuntimeTemplate("my_runtime_template",
name="runtime-template",
display_name="Runtime template",
location="us-central1",
machine_spec={
"machine_type": "e2-standard-4",
},
network_spec={
"enable_internet_access": True,
})
output_bucket = gcp.storage.Bucket("output_bucket",
name="my_bucket",
location="US",
force_destroy=True,
uniform_bucket_level_access=True)
secret = gcp.secretmanager.Secret("secret",
secret_id="secret",
replication={
"auto": {},
})
secret_version = gcp.secretmanager.SecretVersion("secret_version",
secret=secret.id,
secret_data="secret-data")
dataform_repository = gcp.dataform.Repository("dataform_repository",
name="dataform-repository",
display_name="dataform_repository",
npmrc_environment_variables_secret_version=secret_version.id,
kms_key_name="my-key",
labels={
"label_foo1": "label-bar1",
},
git_remote_settings={
"url": "https://github.com/OWNER/REPOSITORY.git",
"default_branch": "main",
"authentication_token_secret_version": secret_version.id,
},
workspace_compilation_overrides={
"default_database": "database",
"schema_suffix": "_suffix",
"table_prefix": "prefix_",
})
schedule = gcp.colab.Schedule("schedule",
display_name="full-schedule",
location="us-west1",
allow_queueing=True,
max_concurrent_run_count="2",
cron="TZ=America/Los_Angeles * * * * *",
max_run_count="5",
start_time="2014-10-02T15:01:23Z",
end_time="2014-10-10T15:01:23Z",
desired_state="ACTIVE",
create_notebook_execution_job_request={
"notebook_execution_job": {
"display_name": "Notebook execution",
"execution_timeout": "86400s",
"dataform_repository_source": {
"commit_sha": "randomsha123",
"dataform_repository_resource_name": dataform_repository.name.apply(lambda name: f"projects/my-project-name/locations/us-west1/repositories/{name}"),
},
"notebook_runtime_template_resource_name": pulumi.Output.all(
project=my_runtime_template.project,
location=my_runtime_template.location,
name=my_runtime_template.name
).apply(lambda resolved_outputs: f"projects/{resolved_outputs['project']}/locations/{resolved_outputs['location']}/notebookRuntimeTemplates/{resolved_outputs['name']}")
,
"gcs_output_uri": output_bucket.name.apply(lambda name: f"gs://{name}"),
"service_account": "my@service-account.com",
},
},
opts = pulumi.ResourceOptions(depends_on=[
my_runtime_template,
output_bucket,
secret_version,
dataform_repository,
]))
package main
import (
"fmt"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/colab"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/dataform"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/secretmanager"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
myRuntimeTemplate, err := colab.NewRuntimeTemplate(ctx, "my_runtime_template", &colab.RuntimeTemplateArgs{
Name: pulumi.String("runtime-template"),
DisplayName: pulumi.String("Runtime template"),
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
}
outputBucket, err := storage.NewBucket(ctx, "output_bucket", &storage.BucketArgs{
Name: pulumi.String("my_bucket"),
Location: pulumi.String("US"),
ForceDestroy: pulumi.Bool(true),
UniformBucketLevelAccess: pulumi.Bool(true),
})
if err != nil {
return err
}
secret, err := secretmanager.NewSecret(ctx, "secret", &secretmanager.SecretArgs{
SecretId: pulumi.String("secret"),
Replication: &secretmanager.SecretReplicationArgs{
Auto: &secretmanager.SecretReplicationAutoArgs{},
},
})
if err != nil {
return err
}
secretVersion, err := secretmanager.NewSecretVersion(ctx, "secret_version", &secretmanager.SecretVersionArgs{
Secret: secret.ID(),
SecretData: pulumi.String("secret-data"),
})
if err != nil {
return err
}
dataformRepository, err := dataform.NewRepository(ctx, "dataform_repository", &dataform.RepositoryArgs{
Name: pulumi.String("dataform-repository"),
DisplayName: pulumi.String("dataform_repository"),
NpmrcEnvironmentVariablesSecretVersion: secretVersion.ID(),
KmsKeyName: pulumi.String("my-key"),
Labels: pulumi.StringMap{
"label_foo1": pulumi.String("label-bar1"),
},
GitRemoteSettings: &dataform.RepositoryGitRemoteSettingsArgs{
Url: pulumi.String("https://github.com/OWNER/REPOSITORY.git"),
DefaultBranch: pulumi.String("main"),
AuthenticationTokenSecretVersion: secretVersion.ID(),
},
WorkspaceCompilationOverrides: &dataform.RepositoryWorkspaceCompilationOverridesArgs{
DefaultDatabase: pulumi.String("database"),
SchemaSuffix: pulumi.String("_suffix"),
TablePrefix: pulumi.String("prefix_"),
},
})
if err != nil {
return err
}
_, err = colab.NewSchedule(ctx, "schedule", &colab.ScheduleArgs{
DisplayName: pulumi.String("full-schedule"),
Location: pulumi.String("us-west1"),
AllowQueueing: pulumi.Bool(true),
MaxConcurrentRunCount: pulumi.String("2"),
Cron: pulumi.String("TZ=America/Los_Angeles * * * * *"),
MaxRunCount: pulumi.String("5"),
StartTime: pulumi.String("2014-10-02T15:01:23Z"),
EndTime: pulumi.String("2014-10-10T15:01:23Z"),
DesiredState: pulumi.String("ACTIVE"),
CreateNotebookExecutionJobRequest: &colab.ScheduleCreateNotebookExecutionJobRequestArgs{
NotebookExecutionJob: &colab.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs{
DisplayName: pulumi.String("Notebook execution"),
ExecutionTimeout: pulumi.String("86400s"),
DataformRepositorySource: &colab.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobDataformRepositorySourceArgs{
CommitSha: pulumi.String("randomsha123"),
DataformRepositoryResourceName: dataformRepository.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("projects/my-project-name/locations/us-west1/repositories/%v", name), nil
}).(pulumi.StringOutput),
},
NotebookRuntimeTemplateResourceName: pulumi.All(myRuntimeTemplate.Project, myRuntimeTemplate.Location, myRuntimeTemplate.Name).ApplyT(func(_args []interface{}) (string, error) {
project := _args[0].(string)
location := _args[1].(string)
name := _args[2].(string)
return fmt.Sprintf("projects/%v/locations/%v/notebookRuntimeTemplates/%v", project, location, name), nil
}).(pulumi.StringOutput),
GcsOutputUri: outputBucket.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("gs://%v", name), nil
}).(pulumi.StringOutput),
ServiceAccount: pulumi.String("my@service-account.com"),
},
},
}, pulumi.DependsOn([]pulumi.Resource{
myRuntimeTemplate,
outputBucket,
secretVersion,
dataformRepository,
}))
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 myRuntimeTemplate = new Gcp.Colab.RuntimeTemplate("my_runtime_template", new()
{
Name = "runtime-template",
DisplayName = "Runtime template",
Location = "us-central1",
MachineSpec = new Gcp.Colab.Inputs.RuntimeTemplateMachineSpecArgs
{
MachineType = "e2-standard-4",
},
NetworkSpec = new Gcp.Colab.Inputs.RuntimeTemplateNetworkSpecArgs
{
EnableInternetAccess = true,
},
});
var outputBucket = new Gcp.Storage.Bucket("output_bucket", new()
{
Name = "my_bucket",
Location = "US",
ForceDestroy = true,
UniformBucketLevelAccess = true,
});
var secret = new Gcp.SecretManager.Secret("secret", new()
{
SecretId = "secret",
Replication = new Gcp.SecretManager.Inputs.SecretReplicationArgs
{
Auto = null,
},
});
var secretVersion = new Gcp.SecretManager.SecretVersion("secret_version", new()
{
Secret = secret.Id,
SecretData = "secret-data",
});
var dataformRepository = new Gcp.Dataform.Repository("dataform_repository", new()
{
Name = "dataform-repository",
DisplayName = "dataform_repository",
NpmrcEnvironmentVariablesSecretVersion = secretVersion.Id,
KmsKeyName = "my-key",
Labels =
{
{ "label_foo1", "label-bar1" },
},
GitRemoteSettings = new Gcp.Dataform.Inputs.RepositoryGitRemoteSettingsArgs
{
Url = "https://github.com/OWNER/REPOSITORY.git",
DefaultBranch = "main",
AuthenticationTokenSecretVersion = secretVersion.Id,
},
WorkspaceCompilationOverrides = new Gcp.Dataform.Inputs.RepositoryWorkspaceCompilationOverridesArgs
{
DefaultDatabase = "database",
SchemaSuffix = "_suffix",
TablePrefix = "prefix_",
},
});
var schedule = new Gcp.Colab.Schedule("schedule", new()
{
DisplayName = "full-schedule",
Location = "us-west1",
AllowQueueing = true,
MaxConcurrentRunCount = "2",
Cron = "TZ=America/Los_Angeles * * * * *",
MaxRunCount = "5",
StartTime = "2014-10-02T15:01:23Z",
EndTime = "2014-10-10T15:01:23Z",
DesiredState = "ACTIVE",
CreateNotebookExecutionJobRequest = new Gcp.Colab.Inputs.ScheduleCreateNotebookExecutionJobRequestArgs
{
NotebookExecutionJob = new Gcp.Colab.Inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs
{
DisplayName = "Notebook execution",
ExecutionTimeout = "86400s",
DataformRepositorySource = new Gcp.Colab.Inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobDataformRepositorySourceArgs
{
CommitSha = "randomsha123",
DataformRepositoryResourceName = dataformRepository.Name.Apply(name => $"projects/my-project-name/locations/us-west1/repositories/{name}"),
},
NotebookRuntimeTemplateResourceName = Output.Tuple(myRuntimeTemplate.Project, myRuntimeTemplate.Location, myRuntimeTemplate.Name).Apply(values =>
{
var project = values.Item1;
var location = values.Item2;
var name = values.Item3;
return $"projects/{project}/locations/{location}/notebookRuntimeTemplates/{name}";
}),
GcsOutputUri = outputBucket.Name.Apply(name => $"gs://{name}"),
ServiceAccount = "my@service-account.com",
},
},
}, new CustomResourceOptions
{
DependsOn =
{
myRuntimeTemplate,
outputBucket,
secretVersion,
dataformRepository,
},
});
});
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.storage.Bucket;
import com.pulumi.gcp.storage.BucketArgs;
import com.pulumi.gcp.secretmanager.Secret;
import com.pulumi.gcp.secretmanager.SecretArgs;
import com.pulumi.gcp.secretmanager.inputs.SecretReplicationArgs;
import com.pulumi.gcp.secretmanager.inputs.SecretReplicationAutoArgs;
import com.pulumi.gcp.secretmanager.SecretVersion;
import com.pulumi.gcp.secretmanager.SecretVersionArgs;
import com.pulumi.gcp.dataform.Repository;
import com.pulumi.gcp.dataform.RepositoryArgs;
import com.pulumi.gcp.dataform.inputs.RepositoryGitRemoteSettingsArgs;
import com.pulumi.gcp.dataform.inputs.RepositoryWorkspaceCompilationOverridesArgs;
import com.pulumi.gcp.colab.Schedule;
import com.pulumi.gcp.colab.ScheduleArgs;
import com.pulumi.gcp.colab.inputs.ScheduleCreateNotebookExecutionJobRequestArgs;
import com.pulumi.gcp.colab.inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs;
import com.pulumi.gcp.colab.inputs.ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobDataformRepositorySourceArgs;
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 myRuntimeTemplate = new RuntimeTemplate("myRuntimeTemplate", RuntimeTemplateArgs.builder()
.name("runtime-template")
.displayName("Runtime template")
.location("us-central1")
.machineSpec(RuntimeTemplateMachineSpecArgs.builder()
.machineType("e2-standard-4")
.build())
.networkSpec(RuntimeTemplateNetworkSpecArgs.builder()
.enableInternetAccess(true)
.build())
.build());
var outputBucket = new Bucket("outputBucket", BucketArgs.builder()
.name("my_bucket")
.location("US")
.forceDestroy(true)
.uniformBucketLevelAccess(true)
.build());
var secret = new Secret("secret", SecretArgs.builder()
.secretId("secret")
.replication(SecretReplicationArgs.builder()
.auto(SecretReplicationAutoArgs.builder()
.build())
.build())
.build());
var secretVersion = new SecretVersion("secretVersion", SecretVersionArgs.builder()
.secret(secret.id())
.secretData("secret-data")
.build());
var dataformRepository = new Repository("dataformRepository", RepositoryArgs.builder()
.name("dataform-repository")
.displayName("dataform_repository")
.npmrcEnvironmentVariablesSecretVersion(secretVersion.id())
.kmsKeyName("my-key")
.labels(Map.of("label_foo1", "label-bar1"))
.gitRemoteSettings(RepositoryGitRemoteSettingsArgs.builder()
.url("https://github.com/OWNER/REPOSITORY.git")
.defaultBranch("main")
.authenticationTokenSecretVersion(secretVersion.id())
.build())
.workspaceCompilationOverrides(RepositoryWorkspaceCompilationOverridesArgs.builder()
.defaultDatabase("database")
.schemaSuffix("_suffix")
.tablePrefix("prefix_")
.build())
.build());
var schedule = new Schedule("schedule", ScheduleArgs.builder()
.displayName("full-schedule")
.location("us-west1")
.allowQueueing(true)
.maxConcurrentRunCount("2")
.cron("TZ=America/Los_Angeles * * * * *")
.maxRunCount("5")
.startTime("2014-10-02T15:01:23Z")
.endTime("2014-10-10T15:01:23Z")
.desiredState("ACTIVE")
.createNotebookExecutionJobRequest(ScheduleCreateNotebookExecutionJobRequestArgs.builder()
.notebookExecutionJob(ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobArgs.builder()
.displayName("Notebook execution")
.executionTimeout("86400s")
.dataformRepositorySource(ScheduleCreateNotebookExecutionJobRequestNotebookExecutionJobDataformRepositorySourceArgs.builder()
.commitSha("randomsha123")
.dataformRepositoryResourceName(dataformRepository.name().applyValue(_name -> String.format("projects/my-project-name/locations/us-west1/repositories/%s", _name)))
.build())
.notebookRuntimeTemplateResourceName(Output.tuple(myRuntimeTemplate.project(), myRuntimeTemplate.location(), myRuntimeTemplate.name()).applyValue(values -> {
var project = values.t1;
var location = values.t2;
var name = values.t3;
return String.format("projects/%s/locations/%s/notebookRuntimeTemplates/%s", project,location,name);
}))
.gcsOutputUri(outputBucket.name().applyValue(_name -> String.format("gs://%s", _name)))
.serviceAccount("my@service-account.com")
.build())
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(
myRuntimeTemplate,
outputBucket,
secretVersion,
dataformRepository)
.build());
}
}
resources:
myRuntimeTemplate:
type: gcp:colab:RuntimeTemplate
name: my_runtime_template
properties:
name: runtime-template
displayName: Runtime template
location: us-central1
machineSpec:
machineType: e2-standard-4
networkSpec:
enableInternetAccess: true
outputBucket:
type: gcp:storage:Bucket
name: output_bucket
properties:
name: my_bucket
location: US
forceDestroy: true
uniformBucketLevelAccess: true
secret:
type: gcp:secretmanager:Secret
properties:
secretId: secret
replication:
auto: {}
secretVersion:
type: gcp:secretmanager:SecretVersion
name: secret_version
properties:
secret: ${secret.id}
secretData: secret-data
dataformRepository:
type: gcp:dataform:Repository
name: dataform_repository
properties:
name: dataform-repository
displayName: dataform_repository
npmrcEnvironmentVariablesSecretVersion: ${secretVersion.id}
kmsKeyName: my-key
labels:
label_foo1: label-bar1
gitRemoteSettings:
url: https://github.com/OWNER/REPOSITORY.git
defaultBranch: main
authenticationTokenSecretVersion: ${secretVersion.id}
workspaceCompilationOverrides:
defaultDatabase: database
schemaSuffix: _suffix
tablePrefix: prefix_
schedule:
type: gcp:colab:Schedule
properties:
displayName: full-schedule
location: us-west1
allowQueueing: true
maxConcurrentRunCount: 2
cron: TZ=America/Los_Angeles * * * * *
maxRunCount: 5
startTime: 2014-10-02T15:01:23Z
endTime: 2014-10-10T15:01:23Z
desiredState: ACTIVE
createNotebookExecutionJobRequest:
notebookExecutionJob:
displayName: Notebook execution
executionTimeout: 86400s
dataformRepositorySource:
commitSha: randomsha123
dataformRepositoryResourceName: projects/my-project-name/locations/us-west1/repositories/${dataformRepository.name}
notebookRuntimeTemplateResourceName: projects/${myRuntimeTemplate.project}/locations/${myRuntimeTemplate.location}/notebookRuntimeTemplates/${myRuntimeTemplate.name}
gcsOutputUri: gs://${outputBucket.name}
serviceAccount: my@service-account.com
options:
dependsOn:
- ${myRuntimeTemplate}
- ${outputBucket}
- ${secretVersion}
- ${dataformRepository}
The allowQueueing property changes behavior when maxConcurrentRunCount is reached: instead of skipping new runs, they queue for execution. The maxRunCount limits total executions; the schedule completes when this count is reached or endTime passes. The startTime and endTime properties define the schedule’s active window. This example also shows dataformRepositorySource as an alternative to gcsNotebookSource, pulling notebooks from a Dataform repository at a specific commit SHA.
Beyond these examples
These snippets focus on specific schedule-level features: cron-based scheduling with timezone support, notebook sources, and schedule lifecycle controls. They’re intentionally minimal rather than full notebook execution pipelines.
The examples may reference pre-existing infrastructure such as service accounts with execution permissions, runtime templates (created inline in examples), and Cloud Storage buckets for notebooks and outputs. They focus on configuring the schedule rather than provisioning all supporting infrastructure.
To keep things focused, common schedule patterns are omitted, including:
- Error handling and retry configuration
- Notification integration for schedule events
- Custom execution timeouts beyond the full example
- Multiple notebook sources in a single schedule
These omissions are intentional: the goal is to illustrate how each schedule feature is wired, not provide drop-in notebook automation modules. See the Colab Schedule resource reference for all available configuration options.
Let's schedule GCP Colab Notebook Executions
Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.
Try Pulumi Cloud for FREEFrequently Asked Questions
Schedule Configuration & Limits
maxConcurrentRunCount limits how many runs can start simultaneously, while maxRunCount sets the total number of runs before the schedule completes. The concurrent limit controls scheduling requests, not notebook execution jobs.maxConcurrentRunCount is reached. Set allowQueueing to true to queue new runs instead of skipping them.endTime is reached or startedRunCount >= maxRunCount. If neither is specified, runs continue until you pause or delete the schedule.Schedule Lifecycle & State
desiredState to PAUSED to pause the schedule, or ACTIVE to start or resume it.startTime and endTime must use RFC 3339 format (e.g., 2014-10-02T15:01:23Z).startTime is not specified, it defaults to the schedule creation time.Notebook Sources & Immutability
createNotebookExecutionJobRequest and project cannot be changed after the schedule is created. To modify these, you must delete and recreate the schedule.gcsNotebookSource or dataformRepositorySource within createNotebookExecutionJobRequest.notebookExecutionJob, but not both simultaneously. Examples show GCS for basic/paused schedules and Dataform for the full example.gcsNotebookSource with the notebook’s uri (in gs://bucket/path format) and optionally its generation for versioning.