google_spanner_instance

An isolated set of Cloud Spanner resources on which databases can be hosted.

To get more information about Instance, see:

Open in Cloud Shell

Example Usage - Spanner Instance Basic

resource "google_spanner_instance" "example" {
  config       = "regional-us-central1"
  display_name = "Test Spanner Instance"
  num_nodes    = 2
  labels = {
    "foo" = "bar"
  }
}
Open in Cloud Shell

Example Usage - Spanner Instance Processing Units

resource "google_spanner_instance" "example" {
  config       = "regional-us-central1"
  display_name = "Test Spanner Instance"
  processing_units    = 200
  labels = {
    "foo" = "bar"
  }
}
Open in Cloud Shell

Example Usage - Spanner Instance With Autoscaling

resource "google_spanner_instance" "example" {
  config       = "regional-us-central1"
  display_name = "Test Spanner Instance"
  autoscaling_config {
    autoscaling_limits {
      // Define the minimum and maximum compute capacity allocated to the instance
      // Either use nodes or processing units to specify the limits,
      // but should use the same unit to set both the min_limit and max_limit.
      max_processing_units            = 3000 // OR max_nodes  = 3
      min_processing_units            = 2000 // OR min_nodes = 2
    }
    autoscaling_targets {
      high_priority_cpu_utilization_percent = 75
      storage_utilization_percent           = 90
    }
  }
  labels = {
    "foo" = "bar"
  }
}
Open in Cloud Shell

Example Usage - Spanner Instance Multi Regional

resource "google_spanner_instance" "example" {
  config       = "nam-eur-asia1"
  display_name = "Multi Regional Instance"
  num_nodes    = 2
  labels = {
    "foo" = "bar"
  }
}

Argument Reference

The following arguments are supported:


The autoscaling_config block supports:

The autoscaling_limits block supports:

The autoscaling_targets 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}}/instances/{{name}}"
  to = google_spanner_instance.default
}

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

$ terraform import google_spanner_instance.default projects/{{project}}/instances/{{name}}
$ terraform import google_spanner_instance.default {{project}}/{{name}}
$ terraform import google_spanner_instance.default {{name}}

User Project Overrides

This resource supports User Project Overrides.