Home / Companies / Spacelift / Blog / Post Details
Content Deep Dive

How to Add Comments in Terraform Code

Blog post from Spacelift

Post Details
Company
Date Published
Author
Mariusz Michalowski
Word Count
1,057
Language
English
Hacker News Points
-
Summary

Terraform comments are used to provide context, explanations, or notes within the code, ensuring team members can quickly grasp the purpose and functionality of configurations. There are two main types of comments in Terraform: single-line comments starting with `#` or `//`, and multi-line comments enclosed in a comment block between `/*` and `*/`. Comments are ignored during execution but are useful for collaboration and improving efficiency. Best practices for writing clear, concise annotations include standardizing the comment style, avoiding over-commenting, focusing on intent, documenting critical resources, and keeping comments up-to-date.