microsoft / PSRule.Rules.CAF

A suite of rules to validate Azure resources against the Cloud Adoption Framework (CAF) using PSRule.
MIT License
62 stars 15 forks source link

Add documentation for overriding default configuration #60

Open BernieWhite opened 3 years ago

BernieWhite commented 3 years ago

PSRule for CAF includes a number of configuration options which include the defaults.

Currently no documentation is provided on overriding these configurations with different values.

majorku5anagi commented 2 years ago

Hi @BernieWhite I believe that locally, I can tamper with Baseline.Rule.yaml, CAF.Common.Rule.ps1, CAF.Name.Rule.ps1, CAF.Tag.Rule.ps1, Config.Rule.yaml but in pipeline only thing that I can think of is to subdivide the operations of running PSRule.Rules.CAF into installing the module, overwritting mentioned .ps1 files with my own prepared in repo and then asserting the rule. If there is a better way, please let me know. I'm not sure if the overriding feature is missing or just documentation on how to do it. Maybe something needs to be added to ps-rule.yaml?

BernieWhite commented 2 years ago

@majorku5anagi You can create a custom baseline or override settings in ps-rule.yaml.


Creating baselines is covered in https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Baseline/. You can create a custom baseline in the .ps-rule/ directory and reference it within your pipeline.

PSRule GitHub Action and Azure DevOps assert task allows a named baseline to be specified by the baseline: parameter.


To override in ps-rule.yaml specify one or more configuration options. For example:

configuration:
  CAF_UseLowerNames: false
  CAF_StoragePrefix: [ 'orgst', 'orgstvm', 'orgdls' ]

The list of configuration defaults is available from the built-in baseline: https://github.com/microsoft/PSRule.Rules.CAF/blob/main/src/PSRule.Rules.CAF/rules/Baseline.Rule.yaml

Not all configuration defaults are currently in use.