Dynamic DependencySubstitution

Hi,
I have an issue configuring the dependency substitution for my project.
I am trying to use a map containing my group:artifact identifiers as keys and the gradle project paths as values:

def depSubs = [
       "com.ith.share:A": ":A",
       "com.ith.share:B": ":B",
       "com.ith.share:CE": "C:frontendCE"
]

Then I define the following dependency substitution rules:
subprojects {
configurations.all {
resolutionStrategy.dependencySubstitution {ds ->
depSubs.each {key, value ->
// not working
// ds.substitute module(key) with ds.project(value)
}

            // working
            ds.substitute module("com.ith.share:A") with ds.project(":A")
            ds.substitute module("com.ith.share:B") with ds.project(":B")
            ds.substitute module("com.ith.share:CE") with ds.project(":C:frontendCE")
        }
    }
}

However iterating over my map and defining the substitution dynamically does not work as commented.
Has anyone got a clue if this is supported by gradle? I am using 6.3.

Thanks