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

resource when condition do not appear to work #556

Closed
sethwenzel opened this issue Sep 24, 2020 · 4 comments
Closed

resource when condition do not appear to work #556

sethwenzel opened this issue Sep 24, 2020 · 4 comments

Comments

@sethwenzel
Copy link

Bicep version
Bicep CLI version 0.1.37-alpha (f88c6d9)

Describe the bug
A clear and concise description of what the bug is vs what you expected to happen

https://github.com/Azure/bicep/blob/master/docs/spec/resources.md#conditions

Should be able to conditionally deploy a resource

syntax looks like

param deployZone bool

resource dnsZone 'Microsoft.Network/dnszones@2018-05-01' when (deployZone) = {
  name: 'myZone'
  location: 'global'
}

Expect this to produce an ARM resource with a "condition": "[expression here]" statement, but instead this errors out.

Example error message:

Error BCP018: Expected the '=' character at this location.

To Reproduce
Create a bicep file with

param deployZone bool

resource dnsZone 'Microsoft.Network/dnszones@2018-05-01' when (deployZone) = {
  name: 'myZone'
  location: 'global'
}

Run bicep -- bicep build test.bicep

view output:

/mnt/c/bicep/test.bicep(3,58) : Error BCP018: Expected the '=' character at this location.
/mnt/c/bicep/test.bicep(4,3) : Error BCP007: This declaration type is not recognized. Specify a parameter, variable, resource, or output declaration.
/mnt/c/bicep/test.bicep(5,3) : Error BCP007: This declaration type is not recognized. Specify a parameter, variable, resource, or output declaration.
/mnt/c/bicep/test.bicep(6,1) : Error BCP007: This declaration type is not recognized. Specify a parameter, variable, resource, or output declaration.

Additional context
Add any other context about the problem here.

@ghost ghost added the Needs: Triage 🔍 label Sep 24, 2020
@alex-frankel
Copy link
Collaborator

Apologies, the spec you linked to should have had a note saying conditions are not implemented yet. We will be getting to that as part of our 0.3 milestone. Tracked with #186

Ok if I close this? I will open a PR to update the spec accordingly.

@sethwenzel
Copy link
Author

I'd rather have the conditionals, but yeah close this and update the spec ;)

@alex-frankel
Copy link
Collaborator

Soon enough!

Thanks for the understanding. Here is the PR: #557

@ghost ghost locked as resolved and limited conversation to collaborators May 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants
@sethwenzel @alex-frankel and others