Schedule a notebook run in Colab Enterprise

Schedule a notebook run

This page shows you how to schedule a notebook run in Colab Enterprise.

Overview

You can schedule a notebook to run immediately one time, or on a recurring schedule.

When you schedule the notebook run, you select a runtime template. Colab Enterprise uses this runtime template to create the runtime that runs your notebook.

The runtime needs specific permissions to run the notebook's code and access Google Cloud services and APIs.

For more information, see Required roles for running the notebook.

After Colab Enterprise completes the notebook run, the results are stored in a shareable Cloud Storage bucket.

Limitations

Colab Enterprise runtimes use Compute Engine quota. See the Compute Engine Allocation quotas page.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Vertex AI, Dataform, and Compute Engine APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Vertex AI, Dataform, and Compute Engine APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

Required roles for scheduling the notebook run

To get the permissions that you need to schedule a notebook run in Colab Enterprise, ask your administrator to grant you the following IAM roles on the project:

For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

Required roles for running the notebook

The principal that runs the notebook needs specific permissions. The principal is either your user account or a service account that you specify, as described in the overview.

To get the permissions that you need to run a notebook in Colab Enterprise, ask your administrator to grant you the following IAM roles:

For more information about granting roles, see Manage access to projects, folders, and organizations.

These predefined roles contain the permissions required to run a notebook in Colab Enterprise. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to run a notebook in Colab Enterprise:

You might also be able to get these permissions with custom roles or other predefined roles.

Use scheduled notebook runs in a Shared VPC network

To use scheduled notebook runs in a Shared VPC network, you must grant additional permissions. See Use Colab Enterprise in a Shared VPC network.

Run a notebook once

To run a notebook one time, you can use the Google Cloud console, the Google Cloud CLI, the Vertex AI Python client library, or Terraform.

Console

  1. In the Google Cloud console, go to the Colab Enterprise My notebooks page.

    Go to My notebooks

  2. In the Region menu, select the region that contains your notebook.

  3. Next to a notebook, click the Notebook actions menu and select Schedule.

  4. In the Schedule name field, enter a name for your schedule.

  5. Click the Runtime template list, and select a runtime template. The runtime template determines the specifications of the runtime that runs your notebook.

  6. Under Run schedule, select One-off to run your notebook as soon as you submit the notebook run.

  7. Next to the Cloud Storage output location field, click Browse to open the Select folder dialog.

  8. Select a Cloud Storage bucket. Or, to create a bucket, click  Create new bucket and complete the dialog.

  9. If you selected a runtime template without end-user credentials enabled, the dialog includes a Service account field. In the Service account field, enter a service account's email address.

  10. Click Submit.

    The notebook run starts immediately.

gcloud

Before using any of the command data below, make the following replacements:

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud colab executions create --display-name="DISPLAY_NAME" \
    --notebook-runtime-template=NOTEBOOK_RUNTIME_TEMPLATE \
    --gcs-notebook-uri=NOTEBOOK_URI \
    --gcs-output-uri=OUTPUT_URI \
    --user-email=USER_EMAIL \
    --project=PROJECT_ID \
    --region=REGION

Windows (PowerShell)

gcloud colab executions create --display-name="DISPLAY_NAME" `
    --notebook-runtime-template=NOTEBOOK_RUNTIME_TEMPLATE `
    --gcs-notebook-uri=NOTEBOOK_URI `
    --gcs-output-uri=OUTPUT_URI `
    --user-email=USER_EMAIL `
    --project=PROJECT_ID `
    --region=REGION

Windows (cmd.exe)

gcloud colab executions create --display-name="DISPLAY_NAME" ^
    --notebook-runtime-template=NOTEBOOK_RUNTIME_TEMPLATE ^
    --gcs-notebook-uri=NOTEBOOK_URI ^
    --gcs-output-uri=OUTPUT_URI ^
    --user-email=USER_EMAIL ^
    --project=PROJECT_ID ^
    --region=REGION

For more information about managing Colab Enterprise notebook runs from the command line, see the gcloud CLI documentation.

Python

Before trying this sample, install the Vertex AI SDK for Python. The Vertex AI Python client library is installed when you install the Vertex AI SDK for Python. For more information, see the Vertex AI SDK for Python API reference documentation.

To run the following code sample, you'll need the Dataform repository ID of your notebook. To get the repository ID of your notebook, you can use Dataform's list_repositories method.

from google.cloud import aiplatform_v1

PROJECT_ID = "my-project"
LOCATION = "us-central1"
REPOSITORY_ID = "b223577f-a3fb-482c-a22c-0658c6602598"
TEMPLATE_ID = "6524523989455339520"

API_ENDPOINT = f"{LOCATION}-aiplatform.googleapis.com"
PARENT = f"projects/{PROJECT_ID}/locations/{LOCATION}"

notebook_service_client = aiplatform_v1.NotebookServiceClient(client_options = {
    "api_endpoint": API_ENDPOINT,
})

operation = notebook_service_client.create_notebook_execution_job(parent=PARENT, notebook_execution_job={
    "display_name": "my-execution-job",

    # Specify a NotebookRuntimeTemplate to source compute configuration from
    "notebook_runtime_template_resource_name": f"projects/{PROJECT_ID}/locations/{LOCATION}/notebookRuntimeTemplates/{TEMPLATE_ID}",

    # Specify a Colab Enterprise notebook to run
    "dataform_repository_source": {
        "dataform_repository_resource_name": f"projects/{PROJECT_ID}/locations/{LOCATION}/repositories/{REPOSITORY_ID}",
    },

    # Specify a Cloud Storage bucket to store output artifacts
    "gcs_output_uri": "gs://my-bucket/",

    # Specify the identity that runs the notebook
    "execution_user": "{EMAIL}",

    # Run as the service account instead
    # "service_account": "my-service-account",
})
print("Waiting for operation to complete...")
result = operation.result()

Terraform

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands. For more information, see the Terraform provider reference documentation.

The following sample uses the google_colab_notebook_execution Terraform resource to run a Colab Enterprise notebook.

resource "google_colab_runtime_template" "my_runtime_template" {
  provider = google-beta
  name = "{{index $.Vars "runtime_template_name"}}"
  display_name = "Runtime template"
  location = "us-central1"

  machine_spec {
    machine_type     = "e2-standard-4"
  }

  network_spec {
    enable_internet_access = true
  }
}

resource "google_storage_bucket" "output_bucket" {
  provider = google-beta
  name          = "{{index $.Vars "bucket"}}"
  location      = "US"
  force_destroy = true
  uniform_bucket_level_access = true
}

resource "google_storage_bucket_object" "notebook" {
  provider = google-beta
  name   = "hello_world.ipynb"
  bucket = google_storage_bucket.output_bucket.name
  content = <<EOF
    {
      "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
    }
    EOF
}

resource "google_colab_notebook_execution" "{{$.PrimaryResourceId}}" {
  provider = google-beta
  notebook_execution_job_id = "{{index $.Vars "notebook_execution_job_id"}}"
  display_name = "Notebook execution full"
  location = "us-central1"

  execution_timeout = "86400s"
  gcs_notebook_source {
  uri = "gs://${google_storage_bucket_object.notebook.bucket}/${google_storage_bucket_object.notebook.name}"
  generation = google_storage_bucket_object.notebook.generation
  }

  service_account = "{{index $.TestEnvVars "service_account"}}"

  gcs_output_uri = "gs://${google_storage_bucket.output_bucket.name}"
  notebook_runtime_template_resource_name = "projects/${google_colab_runtime_template.my_runtime_template.project}/locations/${google_colab_runtime_template.my_runtime_template.location}/notebookRuntimeTemplates/${google_colab_runtime_template.my_runtime_template.name}"

  depends_on = [
    google_storage_bucket_object.notebook,
    google_storage_bucket.output_bucket,
    google_colab_runtime_template.my_runtime_template,
  ]

}

You can view results from completed notebook runs on the Executions page.

Schedule a notebook run

To schedule a notebook run, you can use the Google Cloud console, the gcloud CLI, the Vertex AI Python client library, or Terraform.

Console

  1. In the Google Cloud console, go to the Colab Enterprise My notebooks page.

    Go to My notebooks

  2. In the Region menu, select the region that contains your notebook.

  3. Next to a notebook, click the Notebook actions menu and select Schedule.

  4. In the Schedule name field, enter a name for your schedule.

  5. Click the Runtime template list, and select a runtime template. The runtime template determines the specifications of the runtime that runs your notebook.

  6. Under Run schedule, select Recurring to schedule the notebook run for a specific interval of time.

  7. Complete the scheduling dialog.

  8. Next to the Cloud Storage output location field, click Browse to open the Select folder dialog.

  9. Select a Cloud Storage bucket. Or, to create a bucket, click  Create new bucket and complete the dialog.

  10. If you selected a runtime template without end-user credentials enabled, the dialog includes a Service account field. In the Service account field, enter a service account's email address.

  11. Click Submit.

    Scheduled notebook runs start automatically on the schedule that you set.

gcloud

Before using any of the command data below, make the following replacements:

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud colab schedules create --display-name="DISPLAY_NAME" \
    --cron-schedule=CRON_SCHEDULE \
    --execution-display-name=NOTEBOOK_RUN_NAME \
    --notebook-runtime-template=NOTEBOOK_RUNTIME_TEMPLATE \
    --gcs-notebook-uri=NOTEBOOK_URI \
    --gcs-output-uri=OUTPUT_URI \
    --user-email=USER_EMAIL \
    --project=PROJECT_ID \
    --region=REGION

Windows (PowerShell)

gcloud colab schedules create --display-name="DISPLAY_NAME" `
    --cron-schedule=CRON_SCHEDULE `
    --execution-display-name=NOTEBOOK_RUN_NAME `
    --notebook-runtime-template=NOTEBOOK_RUNTIME_TEMPLATE `
    --gcs-notebook-uri=NOTEBOOK_URI `
    --gcs-output-uri=OUTPUT_URI `
    --user-email=USER_EMAIL `
    --project=PROJECT_ID `
    --region=REGION

Windows (cmd.exe)

gcloud colab schedules create --display-name="DISPLAY_NAME" ^
    --cron-schedule=CRON_SCHEDULE ^
    --execution-display-name=NOTEBOOK_RUN_NAME ^
    --notebook-runtime-template=NOTEBOOK_RUNTIME_TEMPLATE ^
    --gcs-notebook-uri=NOTEBOOK_URI ^
    --gcs-output-uri=OUTPUT_URI ^
    --user-email=USER_EMAIL ^
    --project=PROJECT_ID ^
    --region=REGION

For more information about creating Colab Enterprise notebook schedules from the command line, see the gcloud CLI documentation.

Python

Before trying this sample, install the Vertex AI SDK for Python. The Vertex AI Python client library is installed when you install the Vertex AI SDK for Python. For more information, see the Vertex AI SDK for Python API reference documentation.

To run the following code sample, you'll need the Dataform repository ID of your notebook. To get the repository ID of your notebook, you can use Dataform's list_repositories method.

from google.cloud import aiplatform_v1

PROJECT_ID = "my-project"
LOCATION = "us-central1"
REPOSITORY_ID = "b223577f-a3fb-482c-a22c-0658c6602598"
TEMPLATE_ID = "6524523989455339520"

API_ENDPOINT = f"{LOCATION}-aiplatform.googleapis.com"
PARENT = f"projects/{PROJECT_ID}/locations/{LOCATION}"

schedules_service_client = aiplatform_v1.ScheduleServiceClient(client_options = {
    "api_endpoint": API_ENDPOINT,
})

schedule = schedules_service_client.create_schedule(parent=PARENT, schedule={
    "display_name": "my-notebook-schedule",

    # Time specification. TZ is optional.
    # cron = "* * * * *" to run it in the next minute.
    "cron": "TZ=America/Los_Angeles * * * * *",

    # How many runs the schedule will trigger before it becomes COMPLETED.
    # A Schedule in COMPLETED state will not trigger any more runs.
    "max_run_count": 1,
    "max_concurrent_run_count": 1,

    "create_notebook_execution_job_request": {
      "parent": PARENT,
      "notebook_execution_job": {
        "display_name": "my-execution-job",

        # Specify a NotebookRuntimeTemplate to source compute configuration from
        "notebook_runtime_template_resource_name": f"projects/{PROJECT_ID}/locations/{LOCATION}/notebookRuntimeTemplates/{TEMPLATE_ID}",

        # Specify a Colab Enterprise notebook to run
        "dataform_repository_source": {
            "dataform_repository_resource_name": f"projects/{PROJECT_ID}/locations/{LOCATION}/repositories/{REPOSITORY_ID}",
        },

        # Specify a Cloud Storage bucket to store output artifacts
        "gcs_output_uri": "gs://my-bucket/",


        # Specify the identity that runs the notebook
        "execution_user": "{EMAIL}",

        # Run as the service account instead
        # "service_account": "my-service-account",
    }
  }
})

Terraform

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands. For more information, see the Terraform provider reference documentation.

The following sample uses the google_colab_schedule Terraform resource to schedule a Colab Enterprise notebook run.

resource "google_colab_runtime_template" "my_runtime_template" {
  provider = google-beta
  name = "{{index $.Vars "runtime_template_name"}}"
  display_name = "Runtime template"
  location = "us-central1"

  machine_spec {
    machine_type     = "e2-standard-4"
  }

  network_spec {
    enable_internet_access = true
  }
}

resource "google_storage_bucket" "output_bucket" {
  provider = google-beta
  name          = "{{index $.Vars "bucket"}}"
  location      = "US"
  force_destroy = true
  uniform_bucket_level_access = true
}

resource "google_secret_manager_secret" "secret" {
  provider = google-beta
  secret_id = "{{index $.Vars "secret"}}"
  replication {
    auto {}
  }
}

resource "google_secret_manager_secret_version" "secret_version" {
  provider = google-beta
  secret = google_secret_manager_secret.secret.id
  secret_data = "secret-data"
}

resource "google_dataform_repository" "dataform_repository" {
  provider = google-beta
  name = "{{index $.Vars "dataform_repository"}}"
  display_name = "dataform_repository"
  npmrc_environment_variables_secret_version = google_secret_manager_secret_version.secret_version.id
  kms_key_name = "{{index $.Vars "key_name"}}"

  labels = {
    label_foo1 = "label-bar1"
  }

  git_remote_settings {
      url = "https://github.com/OWNER/REPOSITORY.git"
      default_branch = "main"
      authentication_token_secret_version = google_secret_manager_secret_version.secret_version.id
  }

  workspace_compilation_overrides {
    default_database = "database"
    schema_suffix = "_suffix"
    table_prefix = "prefix_"
  }

}

resource "google_colab_schedule" "{{$.PrimaryResourceId}}" {
  provider = google-beta
  display_name = "{{index $.Vars "display_name"}}"
  location = "{{index $.TestEnvVars "location"}}"
  allow_queueing = true
  max_concurrent_run_count = 2
  cron = "TZ=America/Los_Angeles * * * * *"
  max_run_count = 5
  start_time = "{{index $.Vars "start_time"}}"
  end_time = "{{index $.Vars "end_time"}}"

  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 = "projects/{{index $.TestEnvVars "project_id"}}/locations/{{index $.TestEnvVars "location"}}/repositories/${google_dataform_repository.dataform_repository.name}"
      }

      notebook_runtime_template_resource_name = "projects/${google_colab_runtime_template.my_runtime_template.project}/locations/${google_colab_runtime_template.my_runtime_template.location}/notebookRuntimeTemplates/${google_colab_runtime_template.my_runtime_template.name}"

      gcs_output_uri = "gs://${google_storage_bucket.output_bucket.name}"
      service_account = "{{index $.TestEnvVars "service_account"}}"
    }
  }

  depends_on = [
    google_colab_runtime_template.my_runtime_template,
    google_storage_bucket.output_bucket,
    google_secret_manager_secret_version.secret_version,
    google_dataform_repository.dataform_repository,
  ]
}

In the Google Cloud console, you can view your schedules on the Schedules page. You can view results from the completed notebook runs on the Executions page.

View results

To view notebook run results, you can use the Google Cloud console, the gcloud CLI, or the Vertex AI Python client library.

Console

  1. In the Google Cloud console, go to the Colab Enterprise Executions page.

    Go to Executions

  2. Next to the notebook run that you want to view results for, click View result.

    Colab Enterprise opens the result of the notebook run in a new tab.

  3. To view the result, click the tab.

gcloud

Before using any of the command data below, make the following replacements:

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud colab executions list --project=PROJECT_ID \
    --region=REGION \
    --filter="scheduleResourceName:SCHEDULE_NAME"

Windows (PowerShell)

gcloud colab executions list --project=PROJECT_ID `
    --region=REGION `
    --filter="scheduleResourceName:SCHEDULE_NAME"

Windows (cmd.exe)

gcloud colab executions list --project=PROJECT_ID ^
    --region=REGION ^
    --filter="scheduleResourceName:SCHEDULE_NAME"

For more information about listing Colab Enterprise notebook runs from the command line, see the gcloud CLI documentation.

Python

Before trying this sample, install the Vertex AI SDK for Python. The Vertex AI Python client library is installed when you install the Vertex AI SDK for Python. For more information, see the Vertex AI SDK for Python API reference documentation.

To run the following code sample, you'll need the Dataform repository ID of your notebook. To get the repository ID of your notebook, you can use Dataform's list_repositories method.

from google.cloud import aiplatform_v1

PROJECT_ID = "my-project"
LOCATION = "us-central1"

API_ENDPOINT = f"{LOCATION}-aiplatform.googleapis.com"
PARENT = f"projects/{PROJECT_ID}/locations/{LOCATION}"

notebook_service_client = aiplatform_v1.NotebookServiceClient(client_options = {
    "api_endpoint": API_ENDPOINT,
})

notebook_execution_jobs = notebook_service_client.list_notebook_execution_jobs(parent=PARENT)
notebook_execution_jobs

Delete results

To delete a result from one of your notebook runs, you can use the Google Cloud console or the gcloud CLI.

Console

  1. In the Google Cloud console, go to the Colab Enterprise Executions page.

    Go to Executions

  2. Select the notebook run that you want to delete the result for.

  3. Click  Delete.

  4. To confirm the deletion, click Confirm.

gcloud

Before using any of the command data below, make the following replacements:

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud colab executions delete NOTEBOOK_RUN_ID \
    --project=PROJECT_ID \
    --region=REGION

Windows (PowerShell)

gcloud colab executions delete NOTEBOOK_RUN_ID `
    --project=PROJECT_ID `
    --region=REGION

Windows (cmd.exe)

gcloud colab executions delete NOTEBOOK_RUN_ID ^
    --project=PROJECT_ID ^
    --region=REGION

For more information about deleting Colab Enterprise notebook runs from the command line, see the gcloud CLI documentation.

Share a notebook run's results

You can share notebook run results by providing access to the Cloud Storage bucket that contains your notebook run. Providing this access also grants users access to any other resources in the same Cloud Storage bucket (see Security considerations).

For more information, see the Cloud Storage Sharing and collaboration page.

Security considerations

Your notebook run results are stored as notebook (IPYNB) files in a Cloud Storage bucket. Consider the following when you grant access to this bucket:

When your schedule is configured to use personal credentials, only the specified user is able to modify the schedule or trigger the schedule.

When your schedule is configured to use a service account, only users with the iam.serviceAccounts.actAs permission on the service account is able to modify the schedule or trigger the schedule.

View schedule details

You can view information about a schedule, including:

To view schedule details, you can use the Google Cloud console or the gcloud CLI.

Console

  1. In the Google Cloud console, go to the Colab Enterprise Schedules page.

    Go to Schedules

  2. Click the name of a schedule.

    The Schedule details page opens.

  3. To go back to the Schedules page, click  Back to previous page.

gcloud

Before using any of the command data below, make the following replacements:

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud colab schedules describe SCHEDULE \
    --project=PROJECT_ID \
    --region=REGION

Windows (PowerShell)

gcloud colab schedules describe SCHEDULE `
    --project=PROJECT_ID `
    --region=REGION

Windows (cmd.exe)

gcloud colab schedules describe SCHEDULE ^
    --project=PROJECT_ID ^
    --region=REGION

For more information about viewing Colab Enterprise schedules from the command line, see the gcloud CLI documentation.

Pause, resume, or delete a schedule

To pause, resume, or delete a schedule, you can use the Google Cloud console, the gcloud CLI, or Terraform.

Console

  1. In the Google Cloud console, go to the Colab Enterprise Schedules page.

    Go to Schedules

  2. Select a schedule.

  3. Click  Pause,  Resume, or  Delete.

gcloud

Before using any of the command data below, make the following replacements:

Execute the following command:

Linux, macOS, or Cloud Shell

gcloud colab schedules ACTION SCHEDULE_ID \
    --project=PROJECT_ID \
    --region=REGION

Windows (PowerShell)

gcloud colab schedules ACTION SCHEDULE_ID `
    --project=PROJECT_ID `
    --region=REGION

Windows (cmd.exe)

gcloud colab schedules ACTION SCHEDULE_ID ^
    --project=PROJECT_ID ^
    --region=REGION

For more information about managing Colab Enterprise schedules from the command line, see the gcloud CLI documentation.

Terraform

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands. For more information, see the Terraform provider reference documentation.

The following sample uses the google_colab_schedule Terraform resource to pause or resume a schedule.

To use this sample, change the value of desired_state according to the following:

resource "google_colab_runtime_template" "my_runtime_template" {
  name = "{{index $.Vars "runtime_template_name"}}"
  display_name = "Runtime template"
  location = "us-central1"

  machine_spec {
    machine_type     = "e2-standard-4"
  }

  network_spec {
    enable_internet_access = true
  }
}

resource "google_storage_bucket" "output_bucket" {
  name          = "{{index $.Vars "bucket"}}"
  location      = "US"
  force_destroy = true
  uniform_bucket_level_access = true
}

resource "google_storage_bucket_object" "notebook" {
  name   = "hello_world.ipynb"
  bucket = google_storage_bucket.output_bucket.name
  content = <<EOF
    {
      "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
    }
    EOF
}

resource "google_colab_schedule" "{{$.PrimaryResourceId}}" {
  display_name = "{{index $.Vars "display_name"}}"
  location = "{{index $.TestEnvVars "location"}}"
  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 = "gs://${google_storage_bucket_object.notebook.bucket}/${google_storage_bucket_object.notebook.name}"
        generation = google_storage_bucket_object.notebook.generation
      }

      notebook_runtime_template_resource_name = "projects/${google_colab_runtime_template.my_runtime_template.project}/locations/${google_colab_runtime_template.my_runtime_template.location}/notebookRuntimeTemplates/${google_colab_runtime_template.my_runtime_template.name}"
      gcs_output_uri = "gs://${google_storage_bucket.output_bucket.name}"
      service_account = "{{index $.TestEnvVars "service_account"}}"
      }
  }

  depends_on = [
    google_colab_runtime_template.my_runtime_template,
    google_storage_bucket.output_bucket,
  ]
}

What's next