-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using module outputs in Scope #14381
Comments
ARM is unlikely to remove this restriction in the future, but there are a couple of alternative approaches you could try. Assuming the "naming module" just does some calculations on parameters and returns the results as outputs without deploying any resources, you could try using user-defined functions instead. These can be reused across templates with If the naming module needs to remain a module (i.e., if it deploys resources) and the naming logic can't be factored out, you can use an output of one module as the scope of another by introducing an extra layer of indirection: main.bicep module namingModule 'namingModule.bicep' = {
...
}
module otherModule 'indirection.bicep' = {
name: 'other'
parameters: {
targetResourceGroupName: namingModule.outputs.resourceGroupName
}
} indirection.bicep param targetResourceGroupName string
resource targetRg 'Microsoft.Resources/resourceGroups@2021-04-01' existing = {
name: targetResourceGroupName
}
module mod 'mod.bicep' = {
name: 'mod'
scope: targetRg
...
} I wouldn't recommend this approach if you can avoid it because it is verbose and thwarts many kinds of static analysis (e.g., you cannot use What-If if you follow this pattern). |
Recently using a Naming module to apply standard naming convention's across a project, I ran into the issue that you can't use a output from the Naming module (RG Name) in the Scope. VSCode obviously tell's me the code is broken.
Example:
scope: az.resourceGroup(deploymentsubscription, naming_module_001.outputs.resourceGroupName)
Although you can just code/hardcode RG names is there any potential in the future that a naming module output could be used in the Scope?
The text was updated successfully, but these errors were encountered: