How to create reusable infrastructure with Terraform modules

<p>This is Part 4 of the&nbsp;<a href="https://blog.gruntwork.io/a-comprehensive-guide-to-terraform-b3d32832baca#.b6sun4nkn" rel="noopener ugc nofollow" target="_blank">Comprehensive Guide to Terraform</a>&nbsp;series. In Part 1, you learned&nbsp;<a href="https://blog.gruntwork.io/why-we-use-terraform-and-not-chef-puppet-ansible-saltstack-or-cloudformation-7989dad2865c#.63ls7fpkq" rel="noopener ugc nofollow" target="_blank">why we picked Terraform as our IAC tool of choice and not Chef, Puppet, Ansible, Pulumi, or CloudFormation</a>. In Part 2, you got started with the&nbsp;<a href="https://blog.gruntwork.io/an-introduction-to-terraform-f17df9c6d180" rel="noopener ugc nofollow" target="_blank">basic syntax and features of Terraform and used them to deploy a cluster of web servers on AWS</a>. In Part 3, you saw&nbsp;<a href="https://blog.gruntwork.io/how-to-manage-terraform-state-28f5697e68fa#.r6xdvtxqe" rel="noopener ugc nofollow" target="_blank">how to manage Terraform state, file layout, isolation, and locking</a>. In this post, you&rsquo;ll learn how to create reusable infrastructure with Terraform modules.</p> <p>In the&nbsp;<a href="https://blog.gruntwork.io/how-to-manage-terraform-state-28f5697e68fa#.r6xdvtxqe" rel="noopener ugc nofollow" target="_blank">previous post</a>, you deployed architecture that looks like this:</p> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:700/1*p15BIxgJbl43zpeAVaRM_w.png" style="height:503px; width:700px" /></p> <p>This works great as a first environment, but you typically need at least two environments: one for your team&rsquo;s internal testing (&ldquo;staging&rdquo;) and one that real users can access (&ldquo;production&rdquo;). Ideally, the two environments are nearly identical, though you might run slightly fewer/smaller servers in staging to save money:</p> <p><a href="https://blog.gruntwork.io/how-to-create-reusable-infrastructure-with-terraform-modules-25526d65f73d"><strong>Visit Now</strong></a></p>