Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rules on Terraform variable and outputs #210

Open
JeanFred opened this issue Sep 7, 2020 · 0 comments
Open

Rules on Terraform variable and outputs #210

JeanFred opened this issue Sep 7, 2020 · 0 comments

Comments

@JeanFred
Copy link

JeanFred commented Sep 7, 2020

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]$'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant