A module referred to twice from other modules #14071
Replies: 2 comments
-
I try to keep my modules at the resource group scope but collecting them in a pattern on subscription scope. (Or by "Levels" depending on the intent.)
Depending on how the individual module uses the storage account it could be that just referencing the id directly works, or you might need to do an import with the 'existing' keyword. Obviously the above is only pseudo-coding it so if it works in your specific use case I can't tell - that's just how I try to structure similar use cases. |
Beta Was this translation helpful? Give feedback.
-
According to the docs Suppose I include all the modules separately into the main Bicep module and only refer to their resources across those modules as By importing modules within modules I've tried to achieve automatic dependency resources declaration, so I don't need to manually disable those resources, which don't get required within some particular deployment according to some parameter flags. For example, |
Beta Was this translation helpful? Give feedback.
-
I've a module declaring a storage account, "ModStor"
This module is referred to in VirualMachineScaleSets, "VMSS"
It is also referred to in Cluster module, "Cluster", which in turn is also referred to in "VMSS"
The overall chain of dependencies is like:
This produces several deployment templates within the main ARM template when compiled, and ModStor deployment is then rendered twice with its respective StorageAccount resource deployment in it.
All the modules are declared to be
targetScope = 'resourceGroup'
How to avoid spawning several deployments for the same resource even if it's referred to several times across the dependency chains within the modules references?
Beta Was this translation helpful? Give feedback.
All reactions