Skip to content
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

Module outputs as input parameter is not referenced correctly #13947

Open
scrocquesel-ml150 opened this issue Apr 26, 2024 · 1 comment
Open
Labels
bug Something isn't working
Milestone

Comments

@scrocquesel-ml150
Copy link

scrocquesel-ml150 commented Apr 26, 2024

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

// moduleA.bicep
output webAppName string = 'test'
output nonusedOutput string = 'toto'
// moduleB.bicep
param input moduleAOutputType

type moduleAOutputType = {
    webAppName: string
}

// use input.webAppName
// 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)

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

When passing outputs directly (non working case)

"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

@jeskew
Copy link
Contributor

jeskew commented Apr 26, 2024

This seems like a gap in how Bicep translates output references into ARM JSON expressions. In the second case, the ARM expression should look something like:

"input": {
  "value": "[toObject(items(reference('a').outputs), lambda('kvp', lambdaVariables('kvp').key), lambda('kvp', lambdaVariables('kvp').value.value))]"
}

We block using such an expression directly in Bicep since each property on a reference to module outputs uses the type of the output rather than an object with a value property:

image

@stephaniezyen stephaniezyen added the bug Something isn't working label May 1, 2024
@stephaniezyen stephaniezyen added this to the v1.1 milestone May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

3 participants