Naming does not follow snake_case

Consistent snake_case names make Terraform resources and variables easier to read and maintain.

Description

Terraform configurations commonly use snake_case for resource, variable and module names. Mixing camelCase, PascalCase and kebab-case makes conventions less consistent and can hinder searching and maintenance.

This concerns code quality and team conventions, rather than a direct security vulnerability or syntax error.

Potential impact

  • Mixed naming conventions make resources, variables and modules harder to read.
  • Search, replacement and automation tasks can become more error-prone.
  • Inconsistent Terraform style can slow reviews and maintenance.

Remediation

Use consistent snake_case names such as web_server and db_subnet_group. When renaming existing objects, update their references and migrate resource or module state addresses, for example with moved blocks, to avoid unintended recreation.

Examples

These excerpts compare the Terraform name of an EKS resource. Other properties required to create the cluster are omitted.

Before

hcl
resource "aws_eks_cluster" "productionCluster" {
  name = "production"
}

After

hcl
resource "aws_eks_cluster" "production_cluster" {
  name = "production"
}

The after-example changes the Terraform resource name to production_cluster. The AWS cluster name remains production; an already managed resource also needs its state address migrated.

References