Hi,
I am trying to recreate the same folder/file structure on the remote host ( from the local host ) with neuspaces/system
provider, but the system_folder
resource does not create parent folders, thus I need to somehow create a unique list of folders and create a loop for system_folder
resource ( also depend_on
for system_file
provider is probably needed
too) . Thanks
Pseudo snippet ( not working obviously )
terraform {
required_providers {
system = {
source = "neuspaces/system"
version = "0.3.0"
}
}
}
provider "system" {}
locals {
files = [
"foo/config.yaml",
"bar/config2.yaml",
"foo/bar/nested/nested/config.yaml",
"bar/nested/config.yaml"
]
}
resource "system_folder" "folders" {
for_each = distinct(element(split("/",dirname(local.files)),....))
path = "/tmp/${each.value}"
}
resource "system_file" "files" {
for_each = local.files
path = "/tmp/${each.value}"
content = file(each.value)
depends_on = [system_folder.folders[each.value]]
}
This is required:
/tmp/foo/config.yaml
/tmp/bar/config2.yaml
/tmp/foo/bar/nested/nested/config.yaml
/tmp/bar/nested/config.yaml