Spanner Module

June 10, 2026 ยท View on GitHub

This module handles Spanner instance and database creation in Cluster Toolkit.

Usage

module "spanner_db" {
  source = "./modules/database/spanner"

  project_id    = var.project_id
  instance_name = "my-instance"
  databases = {
    "my-db" = {
      name = "actual-db-name"
    }
  }
}

Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Requirements

NameVersion
terraform>= 1.12.2
google>= 6.0

Providers

NameVersion
google>= 6.0

Modules

No modules.

Resources

NameType
google_spanner_database.dbresource
google_spanner_database_iam_member.memberresource
google_spanner_instance.mainresource

Inputs

NameDescriptionTypeDefaultRequired
configThe name of the instance's configuration.string"regional-us-central1"no
databasesA map of databases to create. Keys are logical names.
map(object({
name = string
deletion_protection = optional(bool, true)
iam_members = optional(list(object({
role = string
member = string
})), [])
}))
{}no
display_nameThe descriptive name for this instance as it appears in UIs.string"Spanner Instance"no
editionThe edition of the Spanner instance (e.g., ENTERPRISE, ENTERPRISE_PLUS, or STANDARD).string"STANDARD"no
instance_nameName of the Spanner instance.stringn/ayes
labelsLabels to apply to the Spanner instance.map(string){}no
processing_unitsThe number of processing units allocated to this instance.number100no
project_idProject ID for Spanner instance.stringn/ayes

Outputs

NameDescription
database_idsA map from logical database name to the actual created database ID.
instance_nameThe name of the Spanner instance.