Hi I am using the below mention terraform to create bigtable cluster and table I want to create multiple tables at a time
Module
resource "google_project_service" "gcp_services" {
for_each = toset(var.gcp_service_list)
project = var.project_id
service = each.key
}
resource "google_bigtable_instance" "instance" {
name = var.bigtable_instance_name
project = var.project_id
deletion_protection = var.deletion_protection
labels = var.labels
cluster {
cluster_id = var.bigtable_cluster_name
zone = var.zone
storage_type = var.bigtable_storage_type
autoscaling_config {
min_nodes = var.min_nodes
max_nodes = var.max_nodes
cpu_target = var.cpu_target
}
}
lifecycle {
prevent_destroy = false
}
depends_on = [
google_project_service.gcp_services
]
}
resource "google_bigtable_table" "table" {
count = var.bigtable_count
name = element(var.bigtable_table_name, count.index)
instance_name = google_bigtable_instance.instance.name
split_keys = [
"a",
"b",
"c"]
project = var.project_id
lifecycle {
prevent_destroy = false
}
column_family {
family = lookup(var.family_type, element(var.bigtable_table_name, count.index ), [] )
}
}
var file
variable "bigtable_count" {
type = number
}
variable "family_type" {
type = map(list(string))
default = {
"test-bigtable-tablename"= ["r", "s"]
"test2-bigtable-tablename"= ["r", "o"]
}
}
#Error
on ../../main.tf line 48, in resource "google_bigtable_table" "table":
│ 48: family = lookup(var.family_type, element(var.bigtable_table_name, count.index ), [])
│ ├────────────────
│ │ count.index is a number, known only after apply
│ │ var.bigtable_table_name is a list of string, known only after apply
│ │ var.family_type is a map of list of string, known only after apply
│
│ Inappropriate value for attribute "family": string required.
╵
Operation failed: failed running terraform plan (exit 1)
You don't need question marks around
[]. It should be: