What are the five best practices I always consider when writing my own Terraform code or helping engineers and organizations write Terraform. In my opinion they are all pretty common sense but lets go over them!
I have found a lot of times in my career - not just with Terraform - that folks tend to overcomplicate their solution prematurely, I have been known to do this myself from time to time. One common mistake I see made with over complication is the excessive use of abstraction, such as creating a module that simply wraps an existing Terraform resource we are now creating a layer on top of that resource that provides little to no value at all. My rule of thumb is if the thing isn't going to be repeated at least five times I am probably not going to abstract it, this is a very personal number but it does give a decent start mark.
When you're writing Terraform think to yourself is what I am writing simple, clear and understandable if it is then you're on your way to having some good code for others to consume!
When writing Terraform modules it is a good idea to opt for creating ones that create a pattern. Organizations tend to have patterns set out for their services, think a database, backend server, and a front end server it is something likely to be repeated within the organization and thus makes a good fit for becoming a module.
Sign up and get started using these in your free account with Scalr.