Retrieving Secrets by name when the name is a variable

You could do it with subexpressions and the secret provider.

Here is an older post that may help: