Best practice for creating module?

Since I started writing modules. I am confused about how to best module and what is the best directory structure for an organization IAAC with over 50 internal modules.

Sometimes, It is good to write dumb modules like when you are writing modules for global resources but terraform suggested and I believe that it is always good to write meaningful modules.

Does anybody have an opinion ?

It’s valid - and makes good sense - to write opinionated modules that are tailored to your organization’s needs. It’s not practical to use entirely generic modules if you need to wrap every single one in a bunch of business logic, or pass the same variables and customizations every time. Go ahead and customize!

I think it’s more important to think about the interfaces between modules, to save you some headaches when you do inevitably need to refactor something. There’s a great writeup of module composition concepts here.

2 Likes