diff --git a/modules/bigtable-instance/README.md b/modules/bigtable-instance/README.md index 1d425a640c..1e9ade9c9e 100644 --- a/modules/bigtable-instance/README.md +++ b/modules/bigtable-instance/README.md @@ -102,13 +102,13 @@ module "bigtable-instance" { | [name](variables.tf#L56) | The name of the Cloud Bigtable instance. | string | ✓ | | | [project_id](variables.tf#L67) | Id of the project where datasets will be created. | string | ✓ | | | [zone](variables.tf#L99) | The zone to create the Cloud Bigtable cluster in. | string | ✓ | | -| [autoscaling_config](variables.tf#L17) | Settings for autoscaling of the instance. Only one of autoscaling_config or num_nodes should be set. | object({…}) | | null | +| [autoscaling_config](variables.tf#L17) | Settings for autoscaling of the instance. If you set this variable, the variable num_nodes is ignored. | object({…}) | | null | | [cluster_id](variables.tf#L28) | The ID of the Cloud Bigtable cluster. | string | | "europe-west1" | | [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. | | | true | | [display_name](variables.tf#L39) | The human-readable display name of the Bigtable instance. | | | null | | [iam](variables.tf#L44) | IAM bindings for topic in {ROLE => [MEMBERS]} format. | map(list(string)) | | {} | | [instance_type](variables.tf#L50) | (deprecated) The instance type to create. One of 'DEVELOPMENT' or 'PRODUCTION'. | string | | null | -| [num_nodes](variables.tf#L61) | The number of nodes in your Cloud Bigtable cluster. For production instances, you must set this option to a specific number if you are not using autoscaling. | number | | null | +| [num_nodes](variables.tf#L61) | The number of nodes in your Cloud Bigtable cluster. This value is ignored if you are using autoscaling. | number | | 1 | | [storage_type](variables.tf#L72) | The storage type to use. | string | | "SSD" | | [table_options_defaults](variables.tf#L78) | Default option of tables created in the BigTable instance. | object({…}) | | {…} | | [tables](variables.tf#L90) | Tables to be created in the BigTable instance, options can be null. | map(object({…})) | | {} | diff --git a/modules/bigtable-instance/main.tf b/modules/bigtable-instance/main.tf index 75e21d5a3a..b5764c3493 100644 --- a/modules/bigtable-instance/main.tf +++ b/modules/bigtable-instance/main.tf @@ -18,6 +18,7 @@ locals { tables = { for k, v in var.tables : k => v != null ? v : var.table_options_defaults } + num_nodes = var.autoscaling_config == null ? var.num_nodes : null } resource "google_bigtable_instance" "default" { @@ -27,7 +28,7 @@ resource "google_bigtable_instance" "default" { cluster_id = var.cluster_id zone = var.zone storage_type = var.storage_type - num_nodes = var.num_nodes + num_nodes = local.num_nodes dynamic "autoscaling_config" { for_each = var.autoscaling_config == null ? [] : [""] content { diff --git a/modules/bigtable-instance/variables.tf b/modules/bigtable-instance/variables.tf index 3629454e7c..84a6013b60 100644 --- a/modules/bigtable-instance/variables.tf +++ b/modules/bigtable-instance/variables.tf @@ -15,7 +15,7 @@ */ variable "autoscaling_config" { - description = "Settings for autoscaling of the instance. Only one of autoscaling_config or num_nodes should be set." + description = "Settings for autoscaling of the instance. If you set this variable, the variable num_nodes is ignored." type = object({ min_nodes = number max_nodes = number @@ -59,9 +59,9 @@ variable "name" { } variable "num_nodes" { - description = "The number of nodes in your Cloud Bigtable cluster. For production instances, you must set this option to a specific number if you are not using autoscaling." + description = "The number of nodes in your Cloud Bigtable cluster. This value is ignored if you are using autoscaling." type = number - default = null + default = 1 } variable "project_id" {