Do you have some framework, or some practises in d...
# terraform
k
Do you have some framework, or some practises in documenting code in terraform? Like that code is more clean, clear, and understanble for others, also in case you need to onboard new person.
t
the beauty of HCL + Terraform is that it is, in general, self-documenting šŸ™‚ I like to call it "executable documentation" for my infrastructure. If you are doing non best practice things such as using local/remote execs, then it is good practice to call out the reason for using these in a comment. There is also this tool, which is pretty useful: https://terraform-docs.io/
for creating code that is clean and less brittle, don't forget DRY (Don't Repeat Yourself)
a
Yeah, Iā€™d subscribe with the use of terraform-docs. However, Iā€™ve seen that usually proper
descriptions
attributes are either ignored, or just overlooked. When those attributes (either for input variables, but also, for output values) are properly described, enriched with enough information and guidance looking for clear ā€œinterfacesā€ and an easy understanding (E.g.: declaring explicitly whatā€™s required, values allowed, validations that are applied, links to references for official docs, or to the Terraform registry docs that belongs to the specific resource being created, etc.), the automation/generation of the docs is the easy part šŸ˜‰ And, as @Thomas Harris mentioned ā€” clear code in a way that resource blocks are concisely named, also helps!
s
take a look at Terramate šŸ™‚ https://github.com/mineiros-io/terramate