Operating on a module collection
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Is your feature request related to a problem? Please describe.**
When using a module together with a for-expression there is sometimes the need to conveniently handle all similar outputs from a module. For instance, let's say I have a module that creates a number of virtual machines, and I have an output with that machine's IP address or hostname. In my `main.bicep` file I might want to collectively output all the output IP addresses/hostnames.
**Describe the solution you'd like**
Given I have a module for a virtual machine like this:
```bicep
// modules/vm.bicep
resource vm 'Microsoft.Compute/virtualMachines@2022-03-01' = {
// details skipped for brevity
}
resource publicIp 'Microsoft.Network/publicIPAddresses@2022-05-01' = {
// details skipped for brevity
}
output hostname string = publicIp.properties.dnsSettings.fqdn
```
In my `main.bicep` file I create a number of vm's with this module, then I would like to output an array of hostnames for all the vm's, collectively referring to them with `vms[*].outputs.hostname`:
```bicep
module vms 'modules/vm.bicep' = [for i in range(0,10): {
// details skipped for brevity
}]
output allHostnames array = vms[*].outputs.hostname
```
Contributor guide
Research direction
Start with the module example in modules/vm.bicep and the consuming expression in main.bicep, then trace how module collections and for-expressions are currently handled. Done means the shown vms[*].outputs.hostname form produces the collective hostname array for the module instances.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100