Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 1.52 KB

File metadata and controls

64 lines (46 loc) · 1.52 KB

style_guide_ordered_variable_arguments

Warns when arguments in a variable block are not in the recommended order:

  1. type
  2. description
  3. default
  4. sensitive
  5. validation block(s)

Arguments not listed above (such as nullable) are not checked.

Example

variable "instance_count" {
  default     = 1
  description = "Number of instances"
  type        = number
}
$ tflint
2 issue(s) found:

Warning: 'description' should be defined before 'default' (recommended order: type, description, default, sensitive, validation) (style_guide_ordered_variable_arguments)

  on main.tf line 3:
   3:   description = "Number of instances"

Reference: https://github.com/miztch/tflint-ruleset-style-guide/blob/v0.2.0/docs/rules/style_guide_ordered_variable_arguments.md

Warning: 'type' should be defined before 'default' (recommended order: type, description, default, sensitive, validation) (style_guide_ordered_variable_arguments)

  on main.tf line 4:
   4:   type        = number

Reference: https://github.com/miztch/tflint-ruleset-style-guide/blob/v0.2.0/docs/rules/style_guide_ordered_variable_arguments.md

Why

https://developer.hashicorp.com/terraform/language/style#variables

We recommend following a consistent order for variable parameters:

  1. Type
  2. Description
  3. Default (optional)
  4. Sensitive (optional)
  5. Validation blocks

How To Fix

Reorder the arguments:

variable "instance_count" {
  type        = number
  description = "Number of instances"
  default     = 1
}