Skip to content

Order of argument definitions (variable, output, module) #22

@nitrocode

Description

@nitrocode

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 = ""
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions