Automatically Shut Down Vertex AI User-Managed Notebooks

Say goodbye to unexpected costs and unnecessary running notebooks

Vertex AI provides two types of notebooks: Google-managed and user-managed.

Google-managed notebooks automatically shut down after a period of inactivity, which helps save costs and prevent billing surprises. However, there isn’t an integrated method for automatically shutting down user-managed notebooks — until now.

Thanks to Jose Brache, you can now add similar functionality to user-managed notebooks in just a few simple steps.

Note that there is a difference in functionality between Google-managed notebooks and Jose’s solution. While managed notebooks shut down after a period of inactivity, Jose’s solution shuts them down after a specified amount of time, regardless of activity. Keep this distinction in mind.



The implementation consists of a Cloud Scheduler and a Cloud Function.

The Cloud Scheduler runs every 5 minutes calling the Cloud Function to check for notebooks that reached the shutdown time.

Per default, the Cloud Function checks Vertex AI Notebooks in the region us-central1if needed, add more regions to the region list.

To set this up, follow the steps in the GitHub repository. Well-done and quick setup using Terraform.

Required Permissions / Roles

It’s worth mentioning that the Cloud Function’s service account needs the following permissions to stop the notebooks and list the projects.

  • resourcemanager.projects.geton the organization level to iterate over all projects in a specific organization. Not needed if you want to execute this in the same project as your Cloud Function is deployed.
  • Notebooks Viewer to list the notebooks in the projects. If you want to shut down the notebook across projects, set this on the organization level, otherwise, on the dedicated projects.


To enable the auto shutdown set the auto-shutdown-seconds metadata tag for the notebooks. You can specify a dedicated shutdown time for each notebook.


Adapt the implementation if you want to apply the same shutdown time to all notebooks without adding an additional metadata tag.

Enjoy your peaceful sleep.

Thanks for reading this quick tip

Your feedback and questions are highly appreciated. You can find me on Twitter @HeyerSascha or connect with me via LinkedIn. Even better, subscribe to my YouTube channel ❤️.

Subscribe to updates, news and more.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related blogs