» google_notebooks_instance

A Cloud AI Platform Notebook instance.

To get more information about Instance, see:

» Example Usage - Notebook Instance Basic

resource "google_notebooks_instance" "instance" {
  provider = google-beta
  name = "notebooks-instance"
  location = "us-west1-a"
  machine_type = "n1-standard-1"
  vm_image {
    project      = "deeplearning-platform-release"
    image_family = "tf-latest-cpu"
  }
}

» Example Usage - Notebook Instance Basic Container

resource "google_notebooks_instance" "instance" {
  provider = google-beta
  name = "notebooks-instance"
  location = "us-west1-a"
  machine_type = "n1-standard-1"
  metadata = {
    proxy-mode = "service_account"
    terraform  = "true"
  }
  container_image {
    repository = "gcr.io/deeplearning-platform-release/base-cpu"
    tag = "latest"
  }
}

» Example Usage - Notebook Instance Basic Gpu

resource "google_notebooks_instance" "instance" {
  provider = google-beta
  name = "notebooks-instance"
  location = "us-west1-a"
  machine_type = "n1-standard-1"

  install_gpu_driver = true
  accelerator_config {
    type         = "NVIDIA_TESLA_T4"
    core_count   = 1
  }
  vm_image {
    project      = "deeplearning-platform-release"
    image_family = "tf-latest-gpu"
  }
}

» Example Usage - Notebook Instance Full

resource "google_notebooks_instance" "instance" {
  provider = google-beta
  name = "notebooks-instance"
  location = "us-central1-a"
  machine_type = "n1-standard-1"

  vm_image {
    project      = "deeplearning-platform-release"
    image_family = "tf-latest-cpu"
  }

  instance_owners = "admin@hashicorptest.com"
  service_account = "emailAddress:my@service-account.com"

  install_gpu_driver = true
  boot_disk_type = "PD_SSD"
  boot_disk_size_gb = 110

  no_public_ip = true
  no_proxy_access = true

  network = data.google_compute_network.my_network.id
  subnet = data.google_compute_subnetwork.my_subnetwork.id

  labels = {
    k = "val"
  }

  metadata = {
    terraform = "true"
  }
}

data "google_compute_network" "my_network" {
  provider = google-beta
  name = "default"
}

data "google_compute_subnetwork" "my_subnetwork" {
  provider = google-beta
  name   = "default"
  region = "us-central1"
}

» Argument Reference

The following arguments are supported:

  • name - (Required) The name specified for the Notebook instance.

  • machine_type - (Required) A reference to a machine type which defines VM kind.

  • location - (Required) A reference to the zone where the machine resides.


  • post_startup_script - (Optional) Path to a Bash script that automatically runs after a notebook instance fully boots up. The path must be a URL or Cloud Storage path (gs://path-to-file/file-name).

  • instance_owners - (Optional) The list of owners of this instance after creation. Format: alias@example.com. Currently supports one owner only. If not specified, all of the service account users of your VM instance's service account can use the instance.

  • service_account - (Optional) The service account on this instance, giving access to other Google Cloud services. You can use any service account within the same project, but you must have the service account user permission to use the instance. If not specified, the Compute Engine default service account is used.

  • accelerator_config - (Optional) The hardware accelerator used on this instance. If you use accelerators, make sure that your configuration has enough vCPUs and memory to support the machineType you have selected. Structure is documented below.

  • install_gpu_driver - (Optional) Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem.

  • custom_gpu_driver_path - (Optional) Specify a custom Cloud Storage path where the GPU driver is stored. If not specified, we'll automatically choose from official GPU drivers.

  • boot_disk_type - (Optional) Possible disk types for notebook instances. Possible values are DISK_TYPE_UNSPECIFIED, PD_STANDARD, PD_SSD, and PD_BALANCED.

  • boot_disk_size_gb - (Optional) The size of the boot disk in GB attached to this instance, up to a maximum of 64000 GB (64 TB). The minimum recommended value is 100 GB. If not specified, this defaults to 100.

  • data_disk_type - (Optional) Possible disk types for notebook instances. Possible values are DISK_TYPE_UNSPECIFIED, PD_STANDARD, PD_SSD, and PD_BALANCED.

  • data_disk_size_gb - (Optional) The size of the data disk in GB attached to this instance, up to a maximum of 64000 GB (64 TB). You can choose the size of the data disk based on how big your notebooks and data are. If not specified, this defaults to 100.

  • no_remove_data_disk - (Optional) If true, the data disk will not be auto deleted when deleting the instance.

  • disk_encryption - (Optional) Disk encryption method used on the boot and data disks, defaults to GMEK. Possible values are DISK_ENCRYPTION_UNSPECIFIED, GMEK, and CMEK.

  • kms_key - (Optional) The KMS key used to encrypt the disks, only applicable if diskEncryption is CMEK. Format: projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}

  • no_public_ip - (Optional) no public IP will be assigned to this instance.

  • no_proxy_access - (Optional) the notebook instance will not register with the proxy..

  • network - (Optional) The name of the VPC that this instance is in. Format: projects/{project_id}/global/networks/{network_id}

  • subnet - (Optional) The name of the subnet that this instance is in. Format: projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}

  • labels - (Optional) Labels to apply to this instance. These can be later modified by the setLabels method. An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

  • metadata - (Optional) Custom metadata to apply to this instance. An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

  • vm_image - (Optional) Use a Compute Engine VM image to start the notebook instance. Structure is documented below.

  • container_image - (Optional) Use a container image to start the notebook instance. Structure is documented below.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The accelerator_config block supports:

  • type - (Required) Type of this accelerator. Possible values are ACCELERATOR_TYPE_UNSPECIFIED, NVIDIA_TESLA_K80, NVIDIA_TESLA_P100, NVIDIA_TESLA_V100, NVIDIA_TESLA_P4, NVIDIA_TESLA_T4, NVIDIA_TESLA_T4_VWS, NVIDIA_TESLA_P100_VWS, NVIDIA_TESLA_P4_VWS, TPU_V2, and TPU_V3.

  • core_count - (Required) Count of cores of this accelerator.

The vm_image block supports:

  • project - (Required) The name of the Google Cloud project that this VM image belongs to. Format: projects/{project_id}

  • image_family - (Optional) Use this VM image family to find the image; the newest image in this family will be used.

  • image_name - (Optional) Use VM image name to find the image.

The container_image block supports:

  • repository - (Required) The path to the container image repository. For example: gcr.io/{project_id}/{imageName}

  • tag - (Optional) The tag of the container image. If not specified, this defaults to the latest tag.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/locations/{{location}}/instances/{{name}}

  • proxy_uri - The proxy endpoint that is used to access the Jupyter notebook.

  • state - The state of this instance.

  • create_time - Instance creation time

  • update_time - Instance update time.

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 15 minutes.
  • update - Default is 15 minutes.
  • delete - Default is 15 minutes.

» Import

Instance can be imported using any of these accepted formats:

$ terraform import google_notebooks_instance.default projects/{{project}}/locations/{{location}}/instances/{{name}}
$ terraform import google_notebooks_instance.default {{project}}/{{location}}/{{name}}
$ terraform import google_notebooks_instance.default {{location}}/{{name}}

» User Project Overrides

This resource supports User Project Overrides.