Closed LockeExile closed 1 month ago
+1.
This issue is quite annoying to find at first. Though the workaround can be simplified like this:
var scope = conditionToUseCustomValue ? trueValue : resourceGroup().name
module ... = {
scope: resourceGroup(scope)
}
That way you can keep your module DRY.
Closing as it's a duplicate of #1876
Bicep version 0.29.47.4906
Describe the bug If a module's scope is defined conditionally with a ternary operator or variable, the output template does not specify any resource group, so the resources in the module always deploy to the parent template's resource group.
To Reproduce The below
main.bicep
demonstrates the conditional scopewhere
OptionalScope.Module.bicep
can be anything, e.g.The generated template does not reference the
storageAccountResourceGroup
parameter at all:Additional context There is a workaround:
The generated template contains
"resourceGroup": "[parameters('storageAccountResourceGroup')]",
as expected.