Azure / Azure/bicep

[Conditions] Can If Module's auto add conditional to parameters

Open
#2,095 6 comments 9 reactions 0 assignees View on GitHub
enhancement intermediate language
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 deploying conditional modules that depend on the outputs of other conditional modules I get deployment not found errors
```
module moduleA './moduleA.bicep' = if(deploy) {
name: 'moduleA'
params: {
name: name
location: location
environment: environment
}
}

module moduleB './moduleB.bicep' = if(deploy) {
name: 'moduleB'
params: {
name: name
location: location
environment: environment
moduleAValue: moduleA.outputs.moduleAValue
}
}
```
To not get these deployment not found errors I am required to add extra conditional logic to the params section
```
module moduleA './moduleA.bicep' = if(deploy) {
name: 'moduleA'
params: {
name: name
location: location
environment: environment
}
}

module moduleB './moduleB.bicep' = if(deploy) {
name: 'moduleB'
params: {
name: name
location: location
environment: environment
moduleAValue: deploy ? moduleA.outputs.moduleAValue : ''
}
}
```
This is extra code and gets very messy with more complex templates and is annoying when there is the luxury of the auto depends on logic

**Describe the solution you'd like**

It would be great if it would automatically add an if condition to the parameter that are coming from if modules in a similar way as its works out the auto depends on

Contributor guide

Open the contributing guide

Research direction

Start with the moduleA.bicep and moduleB.bicep examples in the issue, focusing on how outputs from conditional modules are passed as parameters. Trace the relevant Bicep compilation and deployment-dependency behavior, then define tests for conditional and non-conditional module references. Done means the extra ternary condition is no longer required and deployments avoid the reported not-found errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.