» google_tpu_node

A Cloud TPU instance.

To get more information about Node, see:

» Example Usage - TPU Node Basic

data "google_tpu_tensorflow_versions" "available" {

resource "google_tpu_node" "tpu" {
  name = "test-tpu"
  zone = "us-central1-b"

  accelerator_type   = "v3-8"
  tensorflow_version = data.google_tpu_tensorflow_versions.available.versions[0]
  cidr_block         = ""

» Example Usage - TPU Node Full

data "google_tpu_tensorflow_versions" "available" {

resource "google_tpu_node" "tpu" {
  name = "test-tpu"
  zone = "us-central1-b"

  accelerator_type = "v3-8"

  tensorflow_version = data.google_tpu_tensorflow_versions.available.versions[0]

  description = "Terraform Google Provider test TPU"
  use_service_networking = true
  network = google_service_networking_connection.private_service_connection.network

  labels = {
    foo = "bar"

  scheduling_config {
    preemptible = true

data "google_compute_network" "network" {
  name = "default"

resource "google_compute_global_address" "service_range" {
  name          = "tf-test%{random_suffix}"
  purpose       = "VPC_PEERING"
  address_type  = "INTERNAL"
  prefix_length = 16
  network       = data.google_compute_network.network.id

resource "google_service_networking_connection" "private_service_connection" {
  network                 = data.google_compute_network.network.id
  service                 = "servicenetworking.googleapis.com"
  reserved_peering_ranges = [google_compute_global_address.service_range.name]

» Argument Reference

The following arguments are supported:

  • name - (Required) The immutable name of the TPU.

  • accelerator_type - (Required) The type of hardware accelerators associated with this node.

  • tensorflow_version - (Required) The version of Tensorflow running in the Node.

  • zone - (Required) The GCP location for the TPU.

  • description - (Optional) The user-supplied description of the TPU. Maximum of 512 characters.

  • network - (Optional) The name of a network to peer the TPU node to. It must be a preexisting Compute Engine network inside of the project on which this API has been activated. If none is provided, "default" will be used.

  • cidr_block - (Optional) The CIDR block that the TPU node will use when selecting an IP address. This CIDR block must be a /29 block; the Compute Engine networks API forbids a smaller block, and using a larger block would be wasteful (a node can only consume one IP address). Errors will occur if the CIDR block has already been used for a currently existing TPU node, the CIDR block conflicts with any subnetworks in the user's provided network, or the provided network is peered with another network that is using that CIDR block.

  • use_service_networking - (Optional) Whether the VPC peering for the node is set up through Service Networking API. The VPC Peering should be set up before provisioning the node. If this field is set, cidr_block field should not be specified. If the network that you want to peer the TPU Node to is a Shared VPC network, the node must be created with this this field enabled.

  • scheduling_config - (Optional) Sets the scheduling options for this TPU instance. Structure is documented below.

  • labels - (Optional) Resource labels to represent user provided metadata.

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

The scheduling_config block supports:

  • preemptible - (Required) Defines whether the TPU instance is preemptible.

» 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/{{zone}}/nodes/{{name}}

  • service_account - The service account used to run the tensor flow services within the node. To share resources, including Google Cloud Storage data, with the Tensorflow job running in the Node, this account must have permissions to that data.

  • network_endpoints - The network endpoints where TPU workers can be accessed and sent work. It is recommended that Tensorflow clients of the node first reach out to the first (index 0) entry. Structure is documented below.

The network_endpoints block contains:

  • ip_address - The IP address of this network endpoint.

  • port - The port of this network endpoint.

» 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

Node can be imported using any of these accepted formats:

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

» User Project Overrides

This resource supports User Project Overrides.