Executing shell scripts using the Terraform Shell provider
In the previous recipe, we learned that it is possible to execute local programs or commands with Terraform by using the null_resource
resource.
There is another solution to execute shell scripts to manage external resources by using local commands or an API call.
The solution that we will discuss in this recipe is the use of the Terraform Shell provider in a simple scenario.
Getting ready
To complete this recipe, you’ll need only to have some knowledge about Shell scripting.
This recipe can be applied natively on Linux and macOS operating systems. To perform this recipe on Windows, you can use WSL. The documentation for WSL is available here:
In this recipe, we will mock an API call that manages a book store. We will only use the JSON content created locally in the book.json
file.
The complete source code of this recipe is available here: https://github.com/PacktPublishing/Terraform-Cookbook...