You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 scope
paramstorageAccountNamestring = ''paramstorageAccountResourceGroupstring = ''// Conditionally set scope to this RG or a different one if providedmodulestorageModule'OptionalScope.Module.bicep' = {
name: '${storageAccountName}_ConditionalModule'scope: empty(storageAccountResourceGroup) ? resourceGroup() : resourceGroup(storageAccountResourceGroup)
params: {
storageAccountName: storageAccountName
}
}
where OptionalScope.Module.bicep can be anything, e.g.
paramstorageAccountNamestring = ''paramstorageAccountResourceGroupstring = ''// If RG is provided: explicitly set scope to the provided RGmodulestorageModuleOtherRG'OptionalScope.Module.bicep' = if (!empty(storageAccountResourceGroup)) {
name: '${storageAccountName}_OtherRGModule'scope: resourceGroup(storageAccountResourceGroup)
params: {
storageAccountName: storageAccountName
}
}
// If RG is not provided: leave scope as this RGmodulestorageModuleSameRG'OptionalScope.Module.bicep' = if (empty(storageAccountResourceGroup)) {
name: '${storageAccountName}_SameRGModule'params: {
storageAccountName: storageAccountName
}
}
The generated template contains "resourceGroup": "[parameters('storageAccountResourceGroup')]", as expected.
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.The text was updated successfully, but these errors were encountered: