Skip to content

googleSpannerInstance

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

To get more information about Instance, see:

Example Usage - Spanner Instance Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.spannerInstance.SpannerInstance(this, "example", {
  config: "regional-us-central1",
  display_name: "Test Spanner Instance",
  labels: [
    {
      foo: "bar",
    },
  ],
  num_nodes: 2,
});

Example Usage - Spanner Instance Processing Units

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.spannerInstance.SpannerInstance(this, "example", {
  config: "regional-us-central1",
  display_name: "Test Spanner Instance",
  labels: [
    {
      foo: "bar",
    },
  ],
  processing_units: 200,
});

Example Usage - Spanner Instance Multi Regional

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.spannerInstance.SpannerInstance(this, "example", {
  config: "nam-eur-asia1",
  display_name: "Multi Regional Instance",
  labels: [
    {
      foo: "bar",
    },
  ],
  num_nodes: 2,
});

Argument Reference

The following arguments are supported:

  • name - (Required) A unique identifier for the instance, which cannot be changed after the instance is created. The name must be between 6 and 30 characters in length.

    If not provided, a random string starting with tf will be selected.

  • config - (Required) The name of the instance's configuration (similar but not quite the same as a region) which defines the geographic placement and replication of your databases in this instance. It determines where your data is stored. Values are typically of the form regionalEuropeWest1 , usCentral etc. In order to obtain a valid list please consult the Configuration section of the docs.

  • displayName - (Required) The descriptive name for this instance as it appears in UIs. Must be unique per project and between 4 and 30 characters in length.


  • numNodes - (Optional) The number of nodes allocated to this instance. Exactly one of either node_count or processing_units must be present in terraform.

  • processingUnits - (Optional) The number of processing units allocated to this instance. Exactly one of processing_units or node_count must be present in terraform.

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

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

  • forceDestroy - (Optional) When deleting a spanner instance, this boolean option will delete all backups of this instance. This must be set to true if you created a backup manually in the console.

Attributes Reference

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

  • id - an identifier for the resource with format {{project}}/{{name}}

  • state - Instance status: creating or ready.

Timeouts

This resource provides the following Timeouts configuration options:

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

Import

Instance can be imported using any of these accepted formats:

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