Enterprise HCL Style Guide & Naming Standards¶
1. Resource Naming Conventions¶
- Always use lowercase alphanumeric characters and underscores (
_) in HCL identifiers: - Singleton Resources: If a module manages a single primary resource, name it
this:
2. Variable Validation Rules¶
Every input variable must have a description, an explicit type, and validation where applicable:
variable "cidr_block" {
type = string
description = "IPv4 CIDR block for the VPC (e.g. 10.0.0.0/16)."
validation {
condition = can(cidrhost(var.cidr_block, 0))
error_message = "The cidr_block value must be a valid IPv4 CIDR notation."
}
}
3. Output Quality Standards¶
Always include a description and mark sensitive outputs: