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

Using the resourceGroup function that references a parameter, omits the resourcegroup from being outputted in the compiled ARM template. #15651

Open
mwillebrandscreates opened this issue Nov 21, 2024 · 2 comments

Comments

@mwillebrandscreates
Copy link

mwillebrandscreates commented Nov 21, 2024

Bicep version
Bicep CLI version 0.31.92 (b065093)

Describe the bug
Using the resourceGroup function that references a parameter, omits the resourcegroup from being outputted in the compiled ARM template.

To Reproduce
Create the following bicep files:
main.bicep

targetScope = 'subscription'
param testParam bool

module myModule 'module.bicep' = {
  name: 'myModule'
  scope: testParam ? resourceGroup('rg-a') : resourceGroup('rg-b')
}

module.bicep

targetScope = 'resourceGroup'

resource storage 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  kind: 'BlobStorage'
  location: 'West Europe'
  name: 'storage-${uniqueString('scopetest')}'
  sku: {
    name: 'Standard_LRS'
  }
}

Run az bicep build --file main.bicep
Open the compiled ARM template and note that there's no resourcegroup parameter that contains an expression (there's no resourcegroup parameter at all), and thus the resource will be deployed on subscription level.

Additional context
This might be related to #15570 and #15517. These issues should be solved in the latest version, but do not seem to fix the fact that the resourcegroup is omitted in the compiled ARM template. When not directly referencing a parameter but a static value (like true) the resourcegroup is added to the ARM template.

@GABRIELNGBTUC
Copy link

GABRIELNGBTUC commented Nov 22, 2024

Same solution as there #15270 (comment) (Do the ternary in a variable and reference your variable inside the resourceGroup() call).

Also please upvote this #1876 so that we can get the Bicep or ARM team to unblock this.

@mwillebrandscreates
Copy link
Author

@GABRIELNGBTUC you just saved my life. For the bicep team, as long as the example above isn't supported, is it possible to make sure that the linter returns an error when specifying the above scenario?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

2 participants