Executing local programs with Terraform
As we saw in the previous recipe regarding file manipulation, apart from infrastructure provisioning, Terraform also allows you to run programs or scripts that are located on the local workstation where Terraform has been installed.
In this recipe, we will learn how to execute a local program inside a Terraform configuration.
Getting ready
For this recipe, we will complete the Terraform configuration that we used in the previous recipe to write a file on the local machine. Our goal will be to execute a PowerShell command with Terraform that will read and display the contents of the file that we have written using Terraform.
The technical requirement for this recipe is that we will run this Terraform script on a Windows operating system. You can of course adapt it to run programs on Linux or Mac operating systems or use the Terraform Shell provider, which we will learn about in the next recipe.
The source code...