Azure / Azure/template-analyzer
Add support for parameter to be passed into the rule by user
- Dominant language
- C#
- Stars
- 143
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Description
To make a rule configurable, a parameter may be used to customize the expectation of the rule evaluation for ones own business need. These parameters should be specified in a config file for the Template BPA.
## Current Workaround
Until this feature is implemented, update the value directly in the rule definition.
## Example Config File
``` javascript
{
"parameters": {
"": {
"param1": "value",
...
},
"SQL_Auditing_Enabled": {
"setting": "defaultSetting"
}
}
}
```
Then, the rule definition can reference the parameter and provide the default value of the parameter.
## Example Rule
``` javascript
{
"name": "SQL_Auditing_Enabled",
"description": "Auditing on SQL server should be enabled",
"recommendation": "Enable auditing on your SQL Server",
"helpUri": "https://github.com/Azure/template-analyzer/docs/built-in-bpa-rules.md/#auditing-on-sql-server-should-be-enabled",
"parameters": {
"setting": {
"defaultValue": "defaultSetting"
}
},
"evaluation": {
"resourceType": "Microsoft.Sql/servers",
"where": {
"path": "kind",
"regex": "^((?!analytics).)*$"
},
"evaluate": {
"resourceType": "Microsoft.Sql/servers/auditingSettings",
"path": "properties.auditingSettings.state",
"equals": "[parameters('setting')]"
}
}
```
## Pending decisions
1. How should the parameter be reference? Should it inherently know the JSON path of the parameter from the rule name (e.g. `"[parameters('param1')]"`) or should you have to specify the entire parameters path (e.g. `"[parameters('SQL_Auditing_Enabled.setting')]"`)
2. Where should the config file be located?
Related #54, #52
Contributor guide
Assessment
This issue has not been assessed yet.