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 = "~> 1.0"
project_id = "<PROJECT ID>"
instance_name = "spanner-instance"
instance_display_name = "Sapnner DEV"
instance_size = {
# num_nodes = 2
processing_units = 200
}
instance_config = "regional-europe-west1"
instance_labels = {
"key" = "value"
}
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 |
---|---|---|---|---|
create_instance | Switch to use create OR use existing Spanner Instance | bool |
true |
no |
cron_spec_text | The cron expression for the backup schedule. | string |
"0 2 * * *" |
no |
database_config | The list of databases with their configuration to be created | map(object({ |
{ |
no |
default_backup_schedule_type | Default backup schedule type for new databases. | string |
"NONE" |
no |
edition | The edition of the Spanner instance. | string |
"STANDARD" |
no |
force_destroy | Whether to force destroy the instance and its backups. | bool |
false |
no |
high_priority_cpu_utilization_percent | Target high priority CPU utilization percentage for autoscaling. | number |
60 |
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 | 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 |
max_nodes | Maximum number of nodes for autoscaling. | number |
3 |
no |
max_processing_units | Maximum number of processing units for autoscaling. | number |
3000 |
no |
min_nodes | Minimum number of nodes for autoscaling. | number |
1 |
no |
min_processing_units | Minimum number of processing units for autoscaling. | number |
1000 |
no |
override_max_nodes | Maximum number of nodes for specific replica overrides. | number |
3 |
no |
override_min_nodes | Minimum number of nodes for specific replica overrides. | number |
1 |
no |
project_id | The project ID to deploy to | string |
n/a | yes |
replica_location | Location of the replica for asymmetric autoscaling. | string |
"us-central1" |
no |
storage_utilization_percent | Target storage utilization percentage for autoscaling. | number |
70 |
no |
use_full_backup_spec | Whether to use full backup specification. | bool |
true |
no |
use_incremental_backup_spec | Whether to use incremental backup specification. | bool |
false |
no |
Name | Description |
---|---|
spanner_db_details | Spanner Databases information map |
spanner_instance_id | Spanner Instance ID |
spanner_schedule_backup_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.