How to iterate elements list and map in Terraform?

want to create a folder structure in S3 with Terraform so that it defaults to all environments. The idea is to have structures similar to these:

locals {
  folder = [
  {
    provider = "provider-1",
    process = "batch-process",
    final = ["people","cart"]
  },
  {
    provider = "provider-1",
    process = "online-process",
    final = ["log","order"]
  }]}

Bucket-1

  • provider-1
    • batch-process
      • people
      • cart
    • online-process
      • log
      • order

I managed to create a list with all the S3 directories I would like to have, but I know this is not the most efficient way.

I tried to follow some examples found here but they returned an error. What is the correct way to do this iteration without having to write the entire directory?

S3 buckets don’t really have folders. They have objects whose keys may look like folders and can be traversed like folders in the UI. For example, foo/bar/baz is an object key. It is not an object baz that lives in directory foo/bar.

What are you trying to accomplish?