This module is used to create a Cloud Spanner Instance.
The resources/services/activations/deletions that this module will create/trigger are:
- Creates a Cloud Spanner Instance
- Creates a Cloud Spanner Database
- Creates a Cloud Spanner Database Backup Scheduler
Basic usage of this module is as follows:
module "cloud_spanner" {
source = "terraform-google-modules/cloud-spanner/google"
version = "~> 0.1"
project_id = "<project-id>"
instance_name = "spanner-instance"
instance_display_name = "Spanner dev"
instance_size = {
processing_units = 200
}
instance_config = "regional-europe-west1"
instance_labels = {
"key" = "value"
}
instance_iam = {
"roles/spanner.admin" = [
"user:[email protected]",
],
"roles/spanner.databaseAdmin" = [
"user:[email protected]"
]
}
database_config = {
db1 = {
version_retention_period = "3d"
ddl = [
"CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
"CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)"
]
deletion_protection = false
database_iam = []
enable_backup = false
backup_retention = 86400
create_db = true
}
}
backup_schedule = "0 */6 * * *"
}
Functional examples are included in the examples directory.
Name | Description | Type | Default | Required |
---|---|---|---|---|
backup_schedule | The schedule to be enabled on scheduler to trigger spanner DB backup | string |
"0 */6 * * *" |
no |
backup_schedule_region | The schedule to be enabled on scheduler to trigger spanner DB backup | string |
"us-central1" |
no |
create_instance | Switch to use create OR use existing Spanner Instance | bool |
true |
no |
database_config | The list of databases with their configuration to be created | map(object({ |
{ |
no |
instance_config | 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. | string |
n/a | yes |
instance_display_name | The descriptive name for this instance as it appears in UIs. | string |
"regional-europe-west1" |
no |
instance_iam | The list of permissions on spanner instance | map(list(string)) |
{} |
no |
instance_labels | A set of key/value label pairs to assign to the spanner instance | map(string) |
{} |
no |
instance_name | 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. | string |
"regional-europe-west1" |
no |
instance_size | The sizing configuration of Spanner Instance based on num of nodes OR instance processing units. | object({ |
n/a | yes |
project_id | The project ID to deploy to | string |
n/a | yes |
Name | Description |
---|---|
cloud_scheduler_id | Spanner Backup Cloud Scheduler ID |
spanner_db_details | Spanner Databases information map |
spanner_instance_id | Spanner Instance ID |
workflow_id | Spanner Backup Workflow ID |
These sections describe requirements for using this module.
The following dependencies must be available:
- Terraform v0.13
- Terraform Provider for GCP plugin v3.0
A service account with the following roles must be used to provision the resources of this module:
- Spanner Admin:
roles/spanner.admin
The Project Factory module and the IAM module may be used in combination to provision a service account with the necessary roles applied.
A project with the following APIs enabled must be used to host the resources of this module:
iam.googleapis.com
cloudresourcemanager.googleapis.com
storage-api.googleapis.com
serviceusage.googleapis.com
workflows.googleapis.com
cloudscheduler.googleapis.com
spanner.googleapis.com
pubsub.googleapis.com
logging.googleapis.com
storage.googleapis.com
appengine.googleapis.com
cloudkms.googleapis.com
The Project Factory module can be used to provision a project with the necessary APIs enabled.
Refer to the contribution guidelines for information on contributing to this module.
Please see our security disclosure process.