Azure / Azure/bicep

Module outputs as input parameter is not referenced correctly

Open
#13,947 2 comments 1 reaction 0 assignees View on GitHub
bug Quality Sprint
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 2h
Merged PRs (30d)
79

Description

**Bicep version**
`0.26.170`

**Describe the bug**
I would like to use the output of a module as the input parameter of another module. The syntax is allowed but when at deployment time, the referenced properties is missing the `value` attribute.

**To Reproduce**
```bicep
// moduleA.bicep
output webAppName string = 'test'
output nonusedOutput string = 'toto'
````

```bicep
// moduleB.bicep
param input moduleAOutputType

type moduleAOutputType = {
webAppName: string
}

// use input.webAppName
```

```bicep
// main.bicep
module a 'moduleA.bicep' = {
}

// valid but do not deploy
module b 'moduleB.bicep' = {
params: {
input: a.outputs
}
}

// deploy
module b 'moduleB.bicep' = {
params: {
input: {
webAppName: a.outputs.webAppName
}
}
}
```

**Additional context**
```
Deployment template validation failed: 'The provided value for the template parameter 'input.webAppName' is not valid. Expected a value of type 'String, Uri', but received a value of type 'Object'. Please see https://aka.ms/arm-create-parameter-file for usage details.'. (Code: InvalidTemplate)
```

This is what is generated when creating the object manually (working case)

```json
"input": {
"value": {
"webAppName": "[reference('a').outputs.webAppName.value]"
}
}
```

When passing outputs directly (non working case)

```json
"input": {
"value": "[reference('a').outputs]"
},
```

and then the value is reference with `"[parameters('input').webAppName]"`, so I guess it missed the `.value` part.

Could it be possible to either add the `.value` when the parameter is coming from the outputs object, or automatically create the value mapping ? The former would better as we may not use all properties of the output.

This would help to get rid of a lot mapping boilerplate code

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior using moduleA.bicep, moduleB.bicep, and main.bicep, then compare the generated JSON for direct a.outputs with the manually mapped object. Trace the output-reference generation from this reproduction; done means passing a.outputs generates valid per-property output values and the deployment succeeds without mapping boilerplate.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.