Support for more complex expressions #1033
BernieWhite
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently expressions support comparing any
field,name, ortypeof an object with a predefined set of comparison expressions such asequals,contains,greater...While this handles many cases, advanced use cases may need to revert to PowerShell-based rules.
With PSRule for Azure, we would like to provide a mechanism to generate rules from Azure Policy.
Consider the following Azure Policy code samples from docs:
Example 1
{ "mode": "indexed", "policyRule": { "if": { "value": "[less(length(field('tags')), 3)]", "equals": "true" }, "then": { "effect": "deny" } } }This could be expressed as a rule such as the following. Currently
lessorcountconditions do not count the properties oftagsso this would not work. However this could be added.Example 2
{ "policyRule": { "if": { "value": "[substring(field('name'), 0, 3)]", "equals": "abc" }, "then": { "effect": "audit" } } }This one is a little more tricky, there isn't a PSRule option, the closest approximation would be the following.
The ARM option of using a embedded syntax such as
"[function()]"is not ideal, part of which is the reason for Azure Bicep. An embedded syntax is hard for authors and has a steep learning curve.Without developing a new language such as Bicep we want to make using complex expressions easier by taking advantage of existing schema support.
For example:
Beta Was this translation helpful? Give feedback.
All reactions