Datalake storage account folder level permissions

I need help with creating nested folder structure in Datalake Gen2 storage account, while being able to assign different AD groups with permissions on each folder level.
The depth of folders is not known, but the final path will be provided
eg: a/b/c will be made into [“a”,“b”,“c”]. Now the permissions needed on folders is as below:
a- ADGroupA(rxw)
b- ADGroupB(rwx)
c - ADGroupC(rwx)
I tried putting count/foreach over the list but terraform chooses to apply “a/b/c” before “a/b” or just “a” hence fails saying “a” or “a/b” already exist and needs importing to proceed. Any help would be appreciated. Thanks!