threefoldtech / test_feedback

Apache License 2.0
3 stars 0 forks source link

Terraform QSFS deployment fails #225

Closed VenyaPanou closed 2 years ago

VenyaPanou commented 2 years ago

When deploying QSFS with Terraform, getting an error: Can't access attributes on a primitive-typed values (string) image

Error: Unsupported attribute │ │ on main.tf line 92, in resource "grid_deployment" "qsfs": │ 92: namespace = backends.value.namespace │ ├──────────────── │ │ backends.value is a string, known only after apply │ │ Can't access attributes on a primitive-typed value (string).

No.338 - Test case: TC196

OmarElawady commented 2 years ago

Can you please include the full main.tf file (without secrets)?

VenyaPanou commented 2 years ago

@OmarElawady this ? ( i added valid ssh , when i`m starting deploy) terraform { required_providers { grid = { source = "threefoldtech/grid" } } }

provider "grid" { mnemonics = var.mnemonics network = "test" } variable "mnemonics" { type = string sensitive = true } variable "openssh_key" { type = string sensitive = true } locals { metas = ["meta1", "meta2", "meta3", "meta4"] datas = ["data1", "data2", "data3", "data4"] }

resource "grid_network" "net1" { nodes = [7] ip_range = "10.1.0.0/16" name = "network" description = "newer network" }

resource "grid_deployment" "d1" { node = 7 dynamic "zdbs" { for_each = local.metas content { name = zdbs.value description = "description" password = "password" size = 10 mode = "user" } } dynamic "zdbs" { for_each = local.datas content { name = zdbs.value description = "description" password = "password" size = 10 mode = "seq" } } }

resource "grid_deployment" "qsfs" { node = 7 network_name = grid_network.net1.name ip_range = lookup(grid_network.net1.nodes_ip_range, 7, "") qsfs { name = "qsfs" description = "description6" cache = 10240 # 10 GB minimal_shards = 2 expected_shards = 4 redundant_groups = 0 redundant_nodes = 0 max_zdb_data_dir_size = 512 # 512 MB encryption_algorithm = "AES" encryption_key = "4d778ba3216e4da4231540c92a55f06157cabba802f9b68fb0f78375d2e825af" compression_algorithm = "snappy" metadata { type = "zdb" prefix = "hamada" encryption_algorithm = "AES" encryption_key = "4d778ba3216e4da4231540c92a55f06157cabba802f9b68fb0f78375d2e825af" dynamic "backends" { for_each = [format("http://%s", trimsuffix(grid_deployment.d1.vms[0].ygg_ip, "/24"))] content { address = format("[%s]:%d", backends.value.ips[1], backends.value.port) namespace = backends.value.namespace password = backends.value.password } } } groups { dynamic "backends" { for_each = [format("http://%s", trimsuffix(grid_deployment.d1.vms[0].ygg_ip, "/24"))] content { address = format("[%s]:%d", backends.value.ips[1], backends.value.port) namespace = backends.value.namespace password = backends.value.password } } } } vms { name = "vm" flist = "https://hub.grid.tf/tf-official-apps/base-ubuntu:latest.flist" cpu = 1 memory = 4096 entrypoint = "/sbin/zinit init" planetary = true publicip = true rootfs_size = 30000 env_vars = { SSH_KEY = "" } mounts { disk_name = "qsfs" mount_point = "/qsfs" } } } output "metrics" { value = grid_deployment.qsfs.qsfs[0].metrics_endpoint } output "ygg_ip" { value = grid_deployment.qsfs.vms[0].ygg_ip }

OmarElawady commented 2 years ago

This for_each = [format("http://%s", trimsuffix(grid_deployment.d1.vms[0].ygg_ip, "/24"))] is not correct, as in the example here, it should be something like for_each = [for zdb in grid_deployment.d1.zdbs : zdb if zdb.mode != "seq"] (== seq or != seq depending on whether it's meta or data).

VenyaPanou commented 2 years ago

@OmarElawady yeaaaaaaah now its works))) thanks. I close thit iss