google_tpu_v2_vm

A Cloud TPU VM instance.

To get more information about Vm, see:

Open in Cloud Shell

Example Usage - Tpu V2 Vm Basic

data "google_tpu_v2_runtime_versions" "available" {
  provider = google-beta
}

resource "google_tpu_v2_vm" "tpu" {
  provider = google-beta

  name = "test-tpu"
  zone = "us-central1-c"

  runtime_version = "tpu-vm-tf-2.13.0"
}
Open in Cloud Shell

Example Usage - Tpu V2 Vm Full

data "google_tpu_v2_runtime_versions" "available" {
  provider = google-beta
}

data "google_tpu_v2_accelerator_types" "available" {
  provider = google-beta
}

resource "google_tpu_v2_vm" "tpu" {
  provider = google-beta

  name = "test-tpu"
  zone = "us-central1-c"
  description = "Text description of the TPU."

  runtime_version  = "tpu-vm-tf-2.13.0"

  accelerator_config {
    type     = "V2"
    topology = "2x2"
  }

  cidr_block = "10.0.0.0/29"

  network_config {
    can_ip_forward      = true
    enable_external_ips = true
    network             = google_compute_network.network.id
    subnetwork          = google_compute_subnetwork.subnet.id
  }

  scheduling_config {
    preemptible = true
  }

  shielded_instance_config {
    enable_secure_boot = true
  }

  service_account {
    email = google_service_account.sa.email
    scope = [
      "https://www.googleapis.com/auth/cloud-platform",
    ]
  }

  data_disks {
    source_disk = google_compute_disk.disk.id
    mode        = "READ_ONLY"
  }

  labels = {
    foo = "bar"
  }

  metadata = {
    foo = "bar"
  }

  tags = ["foo"]

  depends_on = [time_sleep.wait_60_seconds]
}

resource "google_compute_subnetwork" "subnet" {
  provider = google-beta

  name          = "tpu-subnet"
  ip_cidr_range = "10.0.0.0/16"
  region        = "us-central1"
  network       = google_compute_network.network.id
}

resource "google_compute_network" "network" {
  provider = google-beta

  name                    = "tpu-net"
  auto_create_subnetworks = false
}

resource "google_service_account" "sa" {
  provider = google-beta

  account_id   = "tpu-sa"
  display_name = "Test TPU VM"
}

resource "google_compute_disk" "disk" {
  provider = google-beta

  name  = "tpu-disk"
  image = "debian-cloud/debian-11"
  size  = 10
  type  = "pd-ssd"
  zone  = "us-central1-c"
}

# Wait after service account creation to limit eventual consistency errors.
resource "time_sleep" "wait_60_seconds" {
  depends_on = [google_service_account.sa]

  create_duration = "60s"
}

Argument Reference

The following arguments are supported:


The network_config block supports:

The service_account block supports:

The scheduling_config block supports:

The data_disks block supports:

The shielded_instance_config block supports:

The accelerator_config block supports:

Attributes Reference

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

The network_endpoints block contains:

The access_config block contains:

The symptoms block contains:

Timeouts

This resource provides the following Timeouts configuration options:

Import

Vm can be imported using any of these accepted formats:

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

import {
  id = "projects/{{project}}/locations/{{zone}}/nodes/{{name}}"
  to = google_tpu_v2_vm.default
}

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

$ terraform import google_tpu_v2_vm.default projects/{{project}}/locations/{{zone}}/nodes/{{name}}
$ terraform import google_tpu_v2_vm.default {{project}}/{{zone}}/{{name}}
$ terraform import google_tpu_v2_vm.default {{zone}}/{{name}}
$ terraform import google_tpu_v2_vm.default {{name}}

User Project Overrides

This resource supports User Project Overrides.