Using another file inside a custom module
In the Creating Terraform module and using it locally recipe of this chapter, we studied the steps to create a basic Terraform module.
We may have scenarios where we need to use another file in the module that does not describe the infrastructure via Terraform (.tf
extension), for example, in the case where the module needs to execute a script locally.
In this recipe, we will study how to use another file in a Terraform module.
Getting ready
For this recipe, we don’t need any prerequisites; we will write the Terraform configuration for the module from scratch.
The goal of this recipe is to create a Terraform module that will execute a Bash script that will perform actions on the local computer (for this recipe, a hello world
display will suffice).
Since we will be running a Bash script as an example, we will run Terraform under a bash console, like in Linux, WSL for Windows or macOS.
It is important...