A Terraform module is a Terraform configuration that contains one or more Terraform resource. Once created, this module can be used in several Terraform configuration files either locally or even remotely.
In this recipe, we will look at the basics of a Terraform module with the steps involved in creating a module and using it locally.
Getting ready
To start this recipe, we will use the Terraform configuration that we have already written in the Provisioning infrastructure in multiple environments recipe in Chapter 2, Writing Terraform Configuration, and whose sources can be found at https://github.com/PacktPublishing/Terraform-Cookbook/tree/master/CHAP05/sample-app.
The module we will create in this recipe will be in charge of providing a Service Plan, one App Service, and an Application Insights resource in Azure. Its source code is available here: https://github.com/PacktPublishing/Terraform-Cookbook/tree/master/CHAP05/moduledemo/Modules...