Schedule GCP Colab Notebook Executions

The gcp:colab/schedule:Schedule resource, part of the Pulumi GCP provider, defines recurring execution schedules for Colab Enterprise notebooks: when they run, how many can run concurrently, and when the schedule completes. This guide focuses on three capabilities: cron-based scheduling, state management (active/paused), and run limits with time bounds.

Schedules depend on RuntimeTemplate resources that define the execution environment, Storage buckets for notebook input and output, and service accounts with permissions to execute notebooks and access resources. The examples are intentionally small. Combine them with your own runtime templates, storage configuration, and IAM setup.

Schedule notebook execution on a cron timer

Data teams run Jupyter notebooks on recurring schedules for ETL pipelines, model training, or report generation. 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 uses standard cron syntax with a timezone prefix (TZ=America/Los_Angeles). At each trigger, the schedule creates a notebook execution job that reads from gcsNotebookSource, runs on the specified notebookRuntimeTemplateResourceName, and writes output 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, you often want to define schedules without immediately starting execution, allowing time for testing before enabling automatic runs.

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}

Setting desiredState to PAUSED creates the schedule without triggering executions. Change it to ACTIVE when ready to start. This lets you validate the notebook, runtime template, and permissions before the first scheduled run.

Control schedule lifecycle with time bounds and run limits

Production schedules need guardrails: maximum run counts to prevent runaway costs, time windows for temporary campaigns, and queueing behavior when concurrent limits are reached.

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 maxRunCount property stops scheduling new runs after five executions. The startTime and endTime properties define a time window; no runs trigger outside this range. Setting allowQueueing to true queues new runs when maxConcurrentRunCount is reached instead of skipping them. This example also shows dataformRepositorySource as an alternative to gcsNotebookSource, pulling notebooks from a Dataform repository at a specific commit.

Beyond these examples

These snippets focus on specific schedule-level features: cron-based scheduling and state control, notebook sources (GCS and Dataform), and concurrency and lifecycle limits. They’re intentionally minimal rather than full notebook execution pipelines.

The examples reference pre-existing infrastructure such as RuntimeTemplate resources for execution environment, Storage buckets for notebook input and output, service accounts with appropriate IAM permissions, and Dataform repositories (for repository-based sources). They focus on configuring the schedule rather than provisioning the surrounding infrastructure.

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

  • Execution timeout configuration (executionTimeout)
  • Custom machine types and accelerators in RuntimeTemplate
  • Network configuration and VPC access
  • Secret management for repository authentication

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 FREE

Frequently Asked Questions

Immutability & Configuration
What properties can't I change after creating a schedule?
The createNotebookExecutionJobRequest and project properties are immutable and cannot be modified after creation. You’ll need to recreate the schedule if these need to change.
What notebook sources can I use for scheduled execution?
You can use gcsNotebookSource to reference a notebook in a GCS bucket, or dataformRepositorySource to reference a notebook in a Dataform repository.
Schedule Lifecycle & State
How do I pause or resume a schedule?
Set desiredState to PAUSED to pause the schedule, or ACTIVE to start or resume it.
When does a schedule stop running?
A schedule completes when either endTime is reached or scheduledRunCount >= maxRunCount. If neither is specified, it continues until you pause or delete it.
What's the default start time for a schedule?
The startTime defaults to the schedule creation time if not specified. You can set it to a future timestamp in RFC 3339 format.
Concurrency & Queueing
What does maxConcurrentRunCount control?
It limits the number of scheduled requests that can start concurrently, not the execution of the notebook jobs themselves. This controls scheduling behavior, not job execution parallelism.
What happens when the concurrent run limit is reached?
By default (when allowQueueing is false), new runs are skipped. Set allowQueueing to true to queue new runs instead.
Time Formats
What time format should I use for startTime and endTime?
Use RFC 3339 format (e.g., 2014-10-02T15:01:23Z) for both startTime and endTime timestamps.

Using a different cloud?

Explore compute guides for other cloud providers: