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
397 stars 86 forks source link

Expand templates without parameters #1161

Open BernieWhite opened 2 years ago

BernieWhite commented 2 years ago

Some templates may not have any parameters or any required parameters particularly if they are built from bicep.

Currently PSRule for Azure will only automatically from CI expands from parameter files. If a template has no parameter file it would not be automatically expanded although could be manually from a PowerShell command line.

We should handle this scenario.


Update: This is already handled for Bicep by configuring expansion options. Issue remains if a template has no required parameters but not parameter file, it isn't currently expanded by any method automatically.

asears commented 2 years ago

Are there steps to manually expand the templates and run the rules? Have encountered this scenario when parameters are passed via Powershell rather than parameter file.

BernieWhite commented 2 years ago

@asears It's a good point. You can expand templates without a parameter file using Export-AzRuleTemplateData if called directly.

That doesn't currently allow a -ParametersObject parameter with a hashtable to pass in parameters from the command-line. Although this could be done.

Also #697 deals with automatically filling parameters from global defaults.

Currently I haven't had any requests to support a -ParametersObject parameter, but admit there could be cases. In most other cases where I have seen this, it's usual in CI where it was easier to just use a declarative parameters file instead of alter the command line to deploy and test parameters using a hashtable.