Dynamic nested resource creation

Hello everyone!
I am trying to create resources based on filesystem folder hierarchy.

In particular I have a fs hierarchy as follows:

├── foldergroup1
│   ├── dashboard1.json
│   └── dashboard2.json
└── foldergroup2
    ├── dashboard1.json
    └── dashboard2.json

So I want a way to create all the grafana folders (foldergroup1 and foldergroup2), and after that their respective dashboards getting the grafanafolders ids.

folder resource: Terraform Registry

dashboards resource:

I’ve never used this provider but I think you just need pointing at how to glob the files

 locals {
  dashboards = fileset("${path.module}", "dashboards/*/*.json")

resource "grafana_dashboard" "metrics" {
  config_json = file(each.key)
1 Like

yes this is the basic idea, but works only if I don’t want to also create folders on grafana.

for each foldergroup I want to create a folder resource to associate with each of its own child dashboards.