How to add secrets for multiple storage accounts with for loop


I’m trying to add multiple secrets for multiple storage accounts to the keyvault in my keyvault module and Im not sure how I can achieve this…

The secrets parts in module looks like below:

secrets = {
    "key1" : { name : "sec1", value : "val1" }
    "key2" : { name : "sec2", value : "val2" }
    "key3" : { name : "sec3", value : "val3" }

secrets accept maps of objects and I’m trying to figure out how to insert all primary keys, SAS etc for storage containers which I have created using for_each.

I was thinking that maybe I could use code like below but not sure how I can use it in terraform:

for index, storageAccount in module.storage_accounts :
      { name = storage-acc-name, value = },
      { name = storage-acc-primary-key, value = storageacc.primary_access_key },
      { name = storage-acc-conn-string, value = storageacc.primary_connection_string }

this could populate entries for all my storage accounts but how to apply this in terraform?