Creating GCP Resource Hierarchy in one run


I want to create the following GCP folders and projects in one run:

========= The yaml file(resources.yaml) : ===========

  - display_name: "Folder1"
    parent: "organizations/ORGANIZATION-NUMBER"
        - project11
        - project12
  - display_name: "Folder2"
    parent: "folders/Folder1"
        - project21


The bare minimum code could be as below:

========= ===============================

locals {
  config                = yamldecode(file("./resources.yaml"))
  folders               = { for folder in lookup(local.config, "folders", []) : folder.display_name => folder }

resource "google_folder" "folder-structure" {
  for_each = local.folders
  display_name = each.key
  parent = lookup(each.value, "parent")


for “parent” parameter, either organization/ORGANIZATION_ID
or folders/FORDER_ID is needed. However, it is not possible to provide the folder ID for “Folder1” before creating it.

To me it seems like a recursion which is not supported in terraform?

Is there any workaround/solution to implement such senario in one run?

Thank you in advance.