Hi community,
I am using HashiCorp Sentinel as policy-as-code framework along with Terraform Enterprise.
I recently faced the challenge to add metadata to the policies, for example to automatically generated an overview of all policies along with additional information, such as internal policy references and a unique ID, that can be used by external teams or auditors that are “not yet familiar with looking at code”.
Interesting metadata per policy would be: unique ID, description, references to policies/documents (e.g. internal and external standards), etc.
My first attempt was to add additional fields to the sentinel.hcl file, as this is already a single location where all policies are listed:
policy "POL001-enforce-storage-accounts-min-tls" {
enforcement_level = "hard-mandatory"
id = "POL001"
name = "Enforce HTTPS on Storage Accounts"
description = "Ensure that `azurerm_storage_account` resources have the `enable_https_traffic_only` flag set to true."
references {
standard = "CIS Microsoft Azure Foundations Benchmark 1.1.0"
control = "3.1 Ensure that 'Secure transfer required' is set to 'Enabled'"
}
Unfortunately, unknown/additional fields are not allowed within a policy block and result in an exception.
Potential other locations would be within a policy.sentinel file directly (as comment at the top?) or completely independent of the policy definition - but both are ugly solutions and cause parsing or maintenance overhead from my perspective.
So my question or feature request would be:
- Did anyone else every tried to work with / add metadata to Sentinel policy definitions? How did you solve it?
- Is it possible to add a “metadata” block or something similar to a policy block definition to allow additional custom field that are not interpreted but can be parsed for own purposes?
Thanks and a good start into the week!