problem to define nfs clients when mounting multiple File systems to different VMs

72 Views Asked by At

I have to mount multiple FS to multiple VMs using a terraform script. for that I defined in "variables.tf" file a variable which belongs to the FS, another that belongs to VMs, and 2 others (one for NFS clients and another one for nfsmount).

the nfsmount variable is defined as bellow:

variable "nfsclients" {
type = map (object({
fileSname = string 
hostnames = list(string) 
permissions = string 
protocol = string
}))

default = {

    "nfs1" = {
        fileSname = "VM1_OPT_SAS"
        hostnames = ["VM1"]
        permissions= "read-write"
        protocol = "nfs4.1"
    }

      "nfs2" = {
        fileSname = "VM2_OPT_SAS"
        hostnames = ["VM2"]
        permissions= "read-write"
        protocol = "nfs4.1"
    }

     "nfs3" = {
        fileSname = "VM3_OPT_SAS"
        hostnames = ["VM3"]
        permissions= "read-write"
        protocol = "nfs4.1"
    }

} 
}

and in the main.tf file, I defined this ressource:

resource "cloudplatform_files_filesystem_nfs_client_v1" "nfs_client" {

for_each = var.nfsclients
filesystem_id = cloudplatform_files_filesystem_v1.test[each.value.fileSname].id
for s in  each.value.hostnames: {
    host = cloudplatform_vcs_server_v1.vm[s].ipv4
    permission = "read-write"
    protocol = "nfs4.1"
    }
}

I got this error:

Error: Invalid block definition
On main.tf line 107: Either a quoted string block label or an opening brace ("{") is expected 
here.

thank you!

0

There are 0 best solutions below