google_notebooks_instance

A Cloud AI Platform Notebook instance.

To get more information about Instance, see:

Open in Cloud Shell

Example Usage - Notebook Instance Basic

resource "google_notebooks_instance" "instance" {
  name = "notebooks-instance"
  location = "us-west1-a"
  machine_type = "e2-medium"
  vm_image {
    project      = "deeplearning-platform-release"
    image_family = "tf-latest-cpu"
  }
}
Open in Cloud Shell

Example Usage - Notebook Instance Basic Stopped

resource "google_notebooks_instance" "instance" {
  name = "notebooks-instance"
  location = "us-west1-a"
  machine_type = "e2-medium"
  vm_image {
    project      = "deeplearning-platform-release"
    image_family = "tf-latest-cpu"
  }
  desired_state = "STOPPED"
}
Open in Cloud Shell

Example Usage - Notebook Instance Basic Container

resource "google_notebooks_instance" "instance" {
  name = "notebooks-instance"
  location = "us-west1-a"
  machine_type = "e2-medium"
  metadata = {
    proxy-mode = "service_account"
    terraform  = "true"
  }
  container_image {
    repository = "gcr.io/deeplearning-platform-release/base-cpu"
    tag = "latest"
  }
}
Open in Cloud Shell

Example Usage - Notebook Instance Basic Gpu

resource "google_notebooks_instance" "instance" {
  name = "notebooks-instance"
  location = "us-west1-a"
  machine_type = "n1-standard-1" // can't be e2 because of accelerator

  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" {
  name = "notebooks-instance"
  location = "us-central1-a"
  machine_type = "e2-medium"

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

  instance_owners = [ "my@service-account.com"]
  service_account = "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"
  }
  service_account_scopes = [
    "https://www.googleapis.com/auth/bigquery",
    "https://www.googleapis.com/auth/devstorage.read_write",
    "https://www.googleapis.com/auth/cloud-platform",
    "https://www.googleapis.com/auth/userinfo.email"
  ]

  tags = ["foo", "bar"]

  disk_encryption = "CMEK"
  kms_key         = "my-crypto-key"
  desired_state = "ACTIVE"
}

data "google_compute_network" "my_network" {
  name = "default"
}

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

Argument Reference

The following arguments are supported:


The accelerator_config block supports:

The shielded_instance_config block supports:

The reservation_affinity block supports:

The vm_image block supports:

The container_image block supports:

Attributes Reference

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

Timeouts

This resource provides the following Timeouts configuration options:

Import

Instance can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import Instance using one of the formats above. For example:

import {
  id = "projects/{{project}}/locations/{{location}}/instances/{{name}}"
  to = google_notebooks_instance.default
}

When using the terraform import command, Instance can be imported using one of the formats above. For example:

$ 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.