Add settings for autoscaling to Bigtable module.
This commit is contained in:
parent
e4fc47a063
commit
00a26d8e98
|
@ -6,10 +6,12 @@ This module allows managing a single BigTable instance, including access configu
|
||||||
|
|
||||||
- [ ] support bigtable_gc_policy
|
- [ ] support bigtable_gc_policy
|
||||||
- [ ] support bigtable_app_profile
|
- [ ] support bigtable_app_profile
|
||||||
|
- [ ] support cluster replicas
|
||||||
|
- [ ] support IAM for tables
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Simple instance with access configuration
|
### Instance with access configuration
|
||||||
|
|
||||||
```hcl
|
```hcl
|
||||||
|
|
||||||
|
@ -32,24 +34,81 @@ module "bigtable-instance" {
|
||||||
}
|
}
|
||||||
# tftest modules=1 resources=4
|
# tftest modules=1 resources=4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Instance with static number of nodes
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
|
||||||
|
module "bigtable-instance" {
|
||||||
|
source = "./fabric/modules/bigtable-instance"
|
||||||
|
project_id = "my-project"
|
||||||
|
name = "instance"
|
||||||
|
cluster_id = "instance"
|
||||||
|
zone = "europe-west1-b"
|
||||||
|
num_nodes = 5
|
||||||
|
}
|
||||||
|
# tftest modules=1 resources=1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Instance with autoscaling (based on CPU only)
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
|
||||||
|
module "bigtable-instance" {
|
||||||
|
source = "./fabric/modules/bigtable-instance"
|
||||||
|
project_id = "my-project"
|
||||||
|
name = "instance"
|
||||||
|
cluster_id = "instance"
|
||||||
|
zone = "europe-southwest1-b"
|
||||||
|
autoscaling_config = {
|
||||||
|
min_nodes = 3
|
||||||
|
max_nodes = 7
|
||||||
|
cpu_target = 70
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# tftest modules=1 resources=1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Instance with autoscaling (based on CPU and/or storage)
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
|
||||||
|
module "bigtable-instance" {
|
||||||
|
source = "./fabric/modules/bigtable-instance"
|
||||||
|
project_id = "my-project"
|
||||||
|
name = "instance"
|
||||||
|
cluster_id = "instance"
|
||||||
|
zone = "europe-southwest1-a"
|
||||||
|
storage_type = "SSD"
|
||||||
|
autoscaling_config = {
|
||||||
|
min_nodes = 3
|
||||||
|
max_nodes = 7
|
||||||
|
cpu_target = 70
|
||||||
|
storage_target = 4096
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# tftest modules=1 resources=1
|
||||||
|
```
|
||||||
|
|
||||||
<!-- BEGIN TFDOC -->
|
<!-- BEGIN TFDOC -->
|
||||||
|
|
||||||
## Variables
|
## Variables
|
||||||
|
|
||||||
| name | description | type | required | default |
|
| name | description | type | required | default |
|
||||||
|---|---|:---:|:---:|:---:|
|
|---|---|:---:|:---:|:---:|
|
||||||
| [name](variables.tf#L45) | The name of the Cloud Bigtable instance. | <code>string</code> | ✓ | |
|
| [name](variables.tf#L56) | The name of the Cloud Bigtable instance. | <code>string</code> | ✓ | |
|
||||||
| [project_id](variables.tf#L56) | Id of the project where datasets will be created. | <code>string</code> | ✓ | |
|
| [project_id](variables.tf#L67) | Id of the project where datasets will be created. | <code>string</code> | ✓ | |
|
||||||
| [zone](variables.tf#L88) | The zone to create the Cloud Bigtable cluster in. | <code>string</code> | ✓ | |
|
| [zone](variables.tf#L99) | The zone to create the Cloud Bigtable cluster in. | <code>string</code> | ✓ | |
|
||||||
| [cluster_id](variables.tf#L17) | The ID of the Cloud Bigtable cluster. | <code>string</code> | | <code>"europe-west1"</code> |
|
| [autoscaling_config](variables.tf#L17) | Settings for autoscaling of the instance. Only one of autoscaling_config or num_nodes should be set. If both are set, num_nodes is ignored. | <code title="object({ min_nodes = number max_nodes = number cpu_target = number storage_target = number })">object({…})</code> | | <code>null</code> |
|
||||||
| [deletion_protection](variables.tf#L23) | 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></code> | | <code>true</code> |
|
| [cluster_id](variables.tf#L28) | The ID of the Cloud Bigtable cluster. | <code>string</code> | | <code>"europe-west1"</code> |
|
||||||
| [display_name](variables.tf#L28) | The human-readable display name of the Bigtable instance. | <code></code> | | <code>null</code> |
|
| [deletion_protection](variables.tf#L34) | 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></code> | | <code>true</code> |
|
||||||
| [iam](variables.tf#L33) | IAM bindings for topic in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
| [display_name](variables.tf#L39) | The human-readable display name of the Bigtable instance. | <code></code> | | <code>null</code> |
|
||||||
| [instance_type](variables.tf#L39) | (deprecated) The instance type to create. One of 'DEVELOPMENT' or 'PRODUCTION'. | <code>string</code> | | <code>null</code> |
|
| [iam](variables.tf#L44) | IAM bindings for topic in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
||||||
| [num_nodes](variables.tf#L50) | The number of nodes in your Cloud Bigtable cluster. | <code>number</code> | | <code>1</code> |
|
| [instance_type](variables.tf#L50) | (deprecated) The instance type to create. One of 'DEVELOPMENT' or 'PRODUCTION'. | <code>string</code> | | <code>null</code> |
|
||||||
| [storage_type](variables.tf#L61) | The storage type to use. | <code>string</code> | | <code>"SSD"</code> |
|
| [num_nodes](variables.tf#L61) | The number of nodes in your Cloud Bigtable cluster. | <code>number</code> | | <code>1</code> |
|
||||||
| [table_options_defaults](variables.tf#L67) | Default option of tables created in the BigTable instance. | <code title="object({ split_keys = list(string) column_family = string })">object({…})</code> | | <code title="{ split_keys = [] column_family = null }">{…}</code> |
|
| [storage_type](variables.tf#L72) | The storage type to use. | <code>string</code> | | <code>"SSD"</code> |
|
||||||
| [tables](variables.tf#L79) | Tables to be created in the BigTable instance, options can be null. | <code title="map(object({ split_keys = list(string) column_family = string }))">map(object({…}))</code> | | <code>{}</code> |
|
| [table_options_defaults](variables.tf#L78) | Default option of tables created in the BigTable instance. | <code title="object({ split_keys = list(string) column_family = string })">object({…})</code> | | <code title="{ split_keys = [] column_family = null }">{…}</code> |
|
||||||
|
| [tables](variables.tf#L90) | Tables to be created in the BigTable instance, options can be null. | <code title="map(object({ split_keys = list(string) column_family = string }))">map(object({…}))</code> | | <code>{}</code> |
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,16 @@ resource "google_bigtable_instance" "default" {
|
||||||
cluster_id = var.cluster_id
|
cluster_id = var.cluster_id
|
||||||
zone = var.zone
|
zone = var.zone
|
||||||
storage_type = var.storage_type
|
storage_type = var.storage_type
|
||||||
|
num_nodes = var.num_nodes
|
||||||
|
dynamic "autoscaling_config" {
|
||||||
|
for_each = var.autoscaling_config == null ? [] : [""]
|
||||||
|
content {
|
||||||
|
min_nodes = var.autoscaling_config.min_nodes
|
||||||
|
max_nodes = var.autoscaling_config.max_nodes
|
||||||
|
cpu_target = var.autoscaling_config.cpu_target
|
||||||
|
storage_target = var.autoscaling_config.storage_target
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
instance_type = var.instance_type
|
instance_type = var.instance_type
|
||||||
|
|
||||||
|
@ -56,8 +66,4 @@ resource "google_bigtable_table" "default" {
|
||||||
family = each.value.column_family
|
family = each.value.column_family
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# lifecycle {
|
|
||||||
# prevent_destroy = true
|
|
||||||
# }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,17 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
variable "autoscaling_config" {
|
||||||
|
description = "Settings for autoscaling of the instance. Only one of autoscaling_config or num_nodes should be set. If both are set, num_nodes is ignored."
|
||||||
|
type = object({
|
||||||
|
min_nodes = number
|
||||||
|
max_nodes = number
|
||||||
|
cpu_target = number
|
||||||
|
storage_target = number
|
||||||
|
})
|
||||||
|
default = null
|
||||||
|
}
|
||||||
|
|
||||||
variable "cluster_id" {
|
variable "cluster_id" {
|
||||||
description = "The ID of the Cloud Bigtable cluster."
|
description = "The ID of the Cloud Bigtable cluster."
|
||||||
type = string
|
type = string
|
||||||
|
@ -50,7 +61,7 @@ variable "name" {
|
||||||
variable "num_nodes" {
|
variable "num_nodes" {
|
||||||
description = "The number of nodes in your Cloud Bigtable cluster."
|
description = "The number of nodes in your Cloud Bigtable cluster."
|
||||||
type = number
|
type = number
|
||||||
default = 1
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "project_id" {
|
variable "project_id" {
|
||||||
|
|
Loading…
Reference in New Issue