2020-06-08 17:40:26 -07:00
# Google Cloud BigTable Module
This module allows managing a single BigTable instance, including access configuration and tables.
## TODO
- [ ] support bigtable_app_profile
2022-11-23 02:26:31 -08:00
- [ ] support IAM for tables
2020-06-08 17:40:26 -07:00
## Examples
2022-11-23 02:26:31 -08:00
### Instance with access configuration
2020-06-08 17:40:26 -07:00
```hcl
2020-11-05 23:11:07 -08:00
module "bigtable-instance" {
2022-12-16 03:53:56 -08:00
source = "./fabric/modules/bigtable-instance"
project_id = "my-project"
name = "instance"
2022-12-28 10:53:17 -08:00
clusters = {
my-cluster = {
zone = "europe-west1-b"
}
}
2022-12-16 03:53:56 -08:00
tables = {
2022-12-22 06:42:06 -08:00
test1 = {},
2020-11-05 23:11:07 -08:00
test2 = {
2022-12-22 08:07:50 -08:00
split_keys = ["a", "b", "c"]
2020-06-09 07:03:10 -07:00
}
}
2022-12-16 03:53:56 -08:00
iam = {
2020-11-05 23:11:07 -08:00
"roles/bigtable.user" = ["user:viewer@testdomain.com"]
2020-06-08 17:40:26 -07:00
}
}
2023-04-14 08:44:37 -07:00
# tftest modules=1 resources=4 inventory=simple.yaml
2020-06-08 17:40:26 -07:00
```
2022-11-23 02:26:31 -08:00
2022-12-22 06:42:06 -08:00
### Instance with tables and column families
```hcl
module "bigtable-instance" {
source = "./fabric/modules/bigtable-instance"
project_id = "my-project"
name = "instance"
2022-12-28 10:53:17 -08:00
clusters = {
my-cluster = {
zone = "europe-west1-b"
}
}
2022-12-22 06:42:06 -08:00
tables = {
test1 = {},
test2 = {
2022-12-22 12:04:42 -08:00
split_keys = ["a", "b", "c"]
column_families = {
cf1 = {}
cf2 = {}
cf3 = {}
}
2022-12-22 06:42:06 -08:00
}
test3 = {
2022-12-22 12:04:42 -08:00
column_families = {
cf1 = {}
}
}
}
}
2023-04-14 08:44:37 -07:00
# tftest modules=1 resources=4 inventory=columns.yaml
2022-12-22 12:04:42 -08:00
```
2022-12-28 10:53:17 -08:00
### Instance with replication enabled
```hcl
module "bigtable-instance" {
source = "./fabric/modules/bigtable-instance"
project_id = "my-project"
name = "instance"
clusters = {
first-cluster = {
zone = "europe-west1-b"
}
second-cluster = {
zone = "europe-southwest1-a"
}
third-cluster = {
zone = "us-central1-b"
}
}
}
2023-04-14 08:44:37 -07:00
# tftest modules=1 resources=1 inventory=replication.yaml
2022-12-28 10:53:17 -08:00
```
2022-12-22 12:04:42 -08:00
### Instance with garbage collection policy
```hcl
module "bigtable-instance" {
source = "./fabric/modules/bigtable-instance"
project_id = "my-project"
name = "instance"
2022-12-28 10:53:17 -08:00
clusters = {
my-cluster = {
zone = "europe-west1-b"
}
}
2022-12-22 12:04:42 -08:00
tables = {
test1 = {
column_families = {
cf1 = {
gc_policy = {
deletion_policy = "ABANDON"
max_age = "18h"
}
}
cf2 = {}
}
}
}
}
2023-04-14 08:44:37 -07:00
# tftest modules=1 resources=3 inventory=gc.yaml
2022-12-22 12:04:42 -08:00
```
### Instance with default garbage collection policy
The default garbage collection policy is applied to any column family that does
not specify a `gc_policy` . If a column family specifies a `gc_policy` , the
default garbage collection policy is ignored for that column family.
```hcl
module "bigtable-instance" {
source = "./fabric/modules/bigtable-instance"
project_id = "my-project"
name = "instance"
2022-12-28 10:53:17 -08:00
clusters = {
my-cluster = {
zone = "europe-west1-b"
}
}
2022-12-22 12:04:42 -08:00
default_gc_policy = {
deletion_policy = "ABANDON"
max_age = "18h"
max_version = 7
}
tables = {
test1 = {
column_families = {
cf1 = {}
cf2 = {}
}
2022-12-22 06:42:06 -08:00
}
}
}
# tftest modules=1 resources=4
```
2022-11-23 02:26:31 -08:00
### Instance with static number of nodes
2022-11-23 06:18:42 -08:00
If you are not using autoscaling settings, you must set a specific number of nodes with the variable `num_nodes` .
2022-11-23 02:26:31 -08:00
```hcl
module "bigtable-instance" {
source = "./fabric/modules/bigtable-instance"
project_id = "my-project"
name = "instance"
2022-12-28 10:53:17 -08:00
clusters = {
my-cluster = {
zone = "europe-west1-b"
num_nodes = 5
}
}
2022-11-23 02:26:31 -08:00
}
2023-04-14 08:44:37 -07:00
# tftest modules=1 resources=1 inventory=static.yaml
2022-11-23 02:26:31 -08:00
```
### Instance with autoscaling (based on CPU only)
2022-11-23 06:18:42 -08:00
If you use autoscaling, you should not set the variable `num_nodes` .
2022-11-23 02:26:31 -08:00
```hcl
module "bigtable-instance" {
2022-12-16 03:53:56 -08:00
source = "./fabric/modules/bigtable-instance"
project_id = "my-project"
name = "instance"
2022-12-28 10:53:17 -08:00
clusters = {
my-cluster = {
zone = "europe-southwest1-b"
autoscaling = {
min_nodes = 3
max_nodes = 7
cpu_target = 70
}
}
2022-11-23 02:26:31 -08:00
}
2022-12-28 10:53:17 -08:00
2022-11-23 02:26:31 -08:00
}
2023-04-14 08:44:37 -07:00
# tftest modules=1 resources=1 inventory=autoscaling1.yaml
2022-11-23 02:26:31 -08:00
```
### Instance with autoscaling (based on CPU and/or storage)
```hcl
module "bigtable-instance" {
2022-12-28 10:53:17 -08:00
source = "./fabric/modules/bigtable-instance"
project_id = "my-project"
name = "instance"
clusters = {
my-cluster = {
zone = "europe-southwest1-a"
storage_type = "SSD"
autoscaling = {
min_nodes = 3
max_nodes = 7
cpu_target = 70
storage_target = 4096
}
}
2022-11-23 02:26:31 -08:00
}
}
2023-04-14 08:44:37 -07:00
# tftest modules=1 resources=1 inventory=autoscaling2.yaml
2022-11-23 02:26:31 -08:00
```
2020-06-08 17:40:26 -07:00
<!-- BEGIN TFDOC -->
## Variables
| name | description | type | required | default |
2021-12-20 23:51:51 -08:00
|---|---|:---:|:---:|:---:|
2022-12-28 10:53:17 -08:00
| [clusters ](variables.tf#L17 ) | Clusters to be created in the BigTable instance. Set more than one cluster to enable replication. If you set autoscaling, num_nodes will be ignored. | < code title = "map(object({ zone = optional(string) storage_type = optional(string) num_nodes = optional(number) autoscaling = optional(object({ min_nodes = number max_nodes = number cpu_target = number storage_target = optional(number) })) }))" > map( object({…})) </ code > | ✓ | |
2024-01-05 00:29:36 -08:00
| [name ](variables.tf#L87 ) | The name of the Cloud Bigtable instance. | < code > string</ code > | ✓ | |
| [project_id ](variables.tf#L92 ) | Id of the project where datasets will be created. | < code > string</ code > | ✓ | |
2022-12-28 10:53:17 -08:00
| [default_autoscaling ](variables.tf#L33 ) | Default settings for autoscaling of clusters. This will be the default autoscaling for any cluster not specifying any autoscaling details. | < code title = "object({ min_nodes = number max_nodes = number cpu_target = number storage_target = optional(number) })" > object({…}) </ code > | | < code > null</ code > |
| [default_gc_policy ](variables.tf#L44 ) | Default garbage collection policy, to be applied to all column families and all tables. Can be override in the tables variable for specific column families. | < code title = "object({ deletion_policy = optional(string) gc_rules = optional(string) mode = optional(string) max_age = optional(string) max_version = optional(string) })" > object({…}) </ code > | | < code > null</ code > |
2023-10-05 08:31:07 -07:00
| [deletion_protection ](variables.tf#L56 ) | Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail. | < code > bool</ code > | | < code > true</ code > |
2023-10-06 02:44:33 -07:00
| [display_name ](variables.tf#L63 ) | The human-readable display name of the Bigtable instance. | < code > string</ code > | | < code > null</ code > |
2024-01-05 00:29:36 -08:00
| [encryption_key ](variables.tf#L69 ) | The KMS key id to used for encryption of the Bigtable instance. | < code > string</ code > | | < code > null</ code > |
| [iam ](variables.tf#L75 ) | IAM bindings for topic in {ROLE => [MEMBERS]} format. | < code > map( list( string)) </ code > | | < code > {} </ code > |
| [labels ](variables.tf#L81 ) | Labels to be attached to the instance. | < code > map( string) </ code > | | < code > {} </ code > |
| [tables ](variables.tf#L97 ) | Tables to be created in the BigTable instance. | < code title = "map(object({ split_keys = optional(list(string), []) column_families = optional(map(object( { gc_policy = optional(object({ deletion_policy = optional(string) gc_rules = optional(string) mode = optional(string) max_age = optional(string) max_version = optional(string) }), null) })), {}) }))" > map( object({…})) </ code > | | < code > {} </ code > |
2020-06-08 17:40:26 -07:00
## Outputs
| name | description | sensitive |
|---|---|:---:|
2023-06-02 07:07:22 -07:00
| [id ](outputs.tf#L17 ) | Fully qualified instance id. | |
2023-08-17 22:51:00 -07:00
| [instance ](outputs.tf#L26 ) | BigTable instance. | |
2022-01-22 04:34:35 -08:00
| [table_ids ](outputs.tf#L35 ) | Map of fully qualified table ids keyed by table name. | |
| [tables ](outputs.tf#L40 ) | Table resources. | |
2020-06-08 17:40:26 -07:00
<!-- END TFDOC -->