Azure / PSRule.Rules.Azure

Rules to validate Azure resources and infrastructure as code (IaC) using PSRule.
https://azure.github.io/PSRule.Rules.Azure/
MIT License
394 stars 86 forks source link

json() function gives error #1656

Closed aavdberg closed 2 years ago

aavdberg commented 2 years ago

Description of the issue

when using:

imageReference: useSharedImage ? json('{\'id\': \'${avdImageTemplataDefinitionId}\'}') : marketPlaceGalleryWindows

in a bicep file it fails the analyzing, but I can deploy it to Azure the correct way.

Error: Unable to expand resources because the source file '/home/runner/work/iac/iac/Azure/Templates/ALZ/LandingZones/Corp/alz-it-eu/avd.bicep' was not valid. An error occurred evaluating expression '[if(parameters('useSharedImage'), json(format('{{''id'': ''{0}''}}', parameters('avdImageTemplataDefinitionId'))), parameters('marketPlaceGalleryWindows'))]' line 21507. Invalid character after parsing property name. Expected ':' but got: i. Path '', line 1, position 3.

To Reproduce

https://github.com/Azure/avdaccelerator/blob/main/workload/bicep/avd-modules/avd-session-hosts.bicep

image

Expected behaviour

should not error out on this

[info] Using repository: PSGallery [info] Installing PSRule: 2.3.2

Checking module: PSRule.Rules.Azure

  • Installing module
  • Using version: 1.20.0-B0028

Captured output from $PSVersionTable:

<img width="579" alt="image" src="https://user-images.githubusercontent.com/22030609/190606842-d1e1ab3e-a0b0-49e7-a228-fe9fb35f5f2d.png">

Additional context

BernieWhite commented 2 years ago

@aavdberg Thanks for reporting the issue. I see the problem and am working on a fix for this which should ship with v1.20.0.

aavdberg commented 2 years ago

Tested it today and it worked, thank you @BernieWhite 🚀👌