Awesome Reviewers

Reviewer · Naming Conventions

Semantic, type-accurate names

Choose identifier names that precisely reflect both the purpose and the underlying data type of what they represent, and keep them consistent across related modules.

Instruction

Choose identifier names that precisely reflect both the purpose and the underlying data type of what they represent, and keep them consistent across related modules.

  • Avoid generic or stuttering names: if a module’s context already implies an action (e.g. create_*, verify_*), don’t repeat that prefix in every nested variable—prefer a simple, consistent name like enabled across sibling create/read modules rather than create_aws_secrets_engine vs verify_create_aws_secrets_engine.
  • Avoid overly generic names that collide in meaning with other modules doing something different (e.g. create_test_servers was ambiguous with an existing “create target infra” module). Pick specific, descriptive names that match established naming idioms in the codebase (e.g. create_external_integration_target, set_up_external_integration_target).
  • Ensure a name’s type is unambiguous from its name: if a variable is a structured “host” object (containing public/private IPv4 and IPv6 addresses), name it host/*_host, not ip_address/*_ip_address. Reserve ip_address strictly for a raw IP string.

Example:

# Bad: name implies a single IP string, but value is a full host object
variable "ldap_host" {
  type = object({ public_ip = string, ipv6 = string, private_ip = string })
}

# Good: name matches the object's shape; a separate field extracts the IP when needed
variable "ldap_host" {
  type = object({ public_ip = string, ipv6 = string, private_ip = string })
}
locals {
  ldap_ip_address = var.ip_version == "6" ? var.ldap_host.ipv6 : var.ldap_host.public_ip
}

Before introducing a new name, check how similar concepts are named elsewhere in the codebase and align with that convention instead of inventing a new one.