Skip to content

no-terraform-comments

Keep Terraform source free of comments; express intent through names and descriptions.

Why

An explicit no-comment policy keeps infrastructure intent in executable names, descriptions and the change review.

Fix

Remove the comment. Preserve necessary context in a descriptive name, description attribute or PR explanation; move tool policy into its supported configuration.

Examples

Before — flagged A Terraform comment duplicates executable intent
main.tf
# Keep this bucket private.
resource "example_bucket" "private" {}
After — preferred A resource name and description express intent
main.tf
resource "example_bucket" "private" {
description = "Private application storage"
}
Before — flagged Keep operators separated when removing an empty block comment
main.tf
locals { value = 1 /**/ + 2 }
After — preferred Whitespace preserves the original Terraform operators
main.tf
locals { value = 1 + 2 }
Autofix output
main.tf
locals { value = 1 + 2 }
Before — flagged Remove an empty Terraform line comment
main.tf
#
locals { value = 1 }
After — preferred The executable Terraform remains unchanged
main.tf
locals { value = 1 }
Autofix output
main.tf
locals { value = 1 }