Sharing Terraform Configuration with Modules
A common problem most developers face in any language is code reuse and how to do it effectively and easily. Hence, the emergence of language, framework, and software packages that are easily reusable in several applications and that can be shared between several teams (such as NuGet, NPM, Bower, PyPI, RubyGems, and many others). In Infrastructure as Code (IaC) in general, we also encounter the same problems of code structure, its homogenization, and its sharing in the company.
In the Provisioning infrastructure in multiple environments recipe in Chapter 3, Scaling Your Infrastructure with Terraform, we learned about some hierarchies of the Terraform configuration, which gave us a partial answer to the question of how to structure a Terraform configuration well. But that doesn’t stop there—Terraform also allows you to create modules with which you can share Terraform configuration between several applications and several...