It’s hard to read the code as I’m on mobile at the moment, but a few notes.
Resource names must have known values when they’re created, so as you noted, it you want to create a resource name from the output of another resource you’d need to do it inside an apply.
However
Creating resources inside an apply is generally not recommend because it means previews aren’t correct.
The best way to move forward for your issue I think is to decide on a name prefix as a string variable and pass that to every resource