tflint icon indicating copy to clipboard operation
tflint copied to clipboard

Order of argument definitions (variable, output, module)

Open nitrocode opened this issue 3 years ago • 3 comments

It would be nice if we can create a linting rule to enforce the order of arguments for vars, outputs, and modules

terraform_module_argument_order
rule "terraform_module_argument_order" {
  enabled = true
  order   = ["source", "version", "count", "for_each"]
}

This would work

module "example" {
  source  = ""
  version = ""
}

This would fail

module "example" {
  version = ""
  source  = ""
}
terraform_variable_argument_order
rule "terraform_variable_argument_order" {
  enabled = true
  order   = ["type", "description", "default", "sensitive", "validation"]
}

This would work

variable "example" {
  type        = "string"
  description = ""
  default     = ""
  sensitive   = true
  validation {}
}

This would fail

variable "example" {
  description = ""
  type        = "string"
  default     = ""
  sensitive   = true
  validation {}
}
terraform_output_argument_order
rule "terraform_output_argument_order" {
  enabled = true
  order   = ["description", "value"]
}

This would work

output "example" {
  description = ""
  type        = ""
}

This would fail

output "example" {
  type        = ""
  description = ""
}

nitrocode avatar May 13 '22 17:05 nitrocode