stelligent/config-lint

Rules on Terraform variable and outputs

Opened this issue · 0 comments

According to https://stelligent.github.io/config-lint/#/terraform, rules can be applied to outputs and variables.

However, I have not been able to make it work (as far as I can see there is no example provided in the docs, nor in the built-in rules)

Here is a minimal example:

---
version: 1
description: Terraform rules
type: Terraform
files:
  - "*.tf"
rules:

  - id: FOO_data
    message: "Foo"
    severity: FAILURE
    category: data
    assertions:
    - key: description
      op: present

  - id: FOO_vars
    message: "Foo"
    severity: FAILURE
    category: variable
    assertions:
    - key: description
      op: present

  - id: FOO_output
    message: "Foo"
    severity: FAILURE
    category: output
    assertions:
    - key: description
      op: present
variable "foo" {
  description = "Foo"
}

variable "bar" {

}

data "aws_prefix_list" "baz" {
  name = "baz"
}

output "bak" {
  value = "bak"
}

Unless I am mistaken, this should fail on the bar variable block and on the output but it does not (The rule on data does fail, and is there to ensure my syntax is correct).

Am I doing something wrong?

(My actual use case is to enforce naming convention, and the rule is thus [1], but I went for a simpler version in the reproduction example, in the case that __name__ was the issue)
[1]

  - id: TF_VARIABLES_NAMING_CONVENTION
    category: variable
    - key: __name__
      op: regex
      value: '^[a-z][a-z0-9_]{0,1}[a-z0-9]$'