-
Book Overview & Buying
-
Table Of Contents
Terraform Cookbook - Second Edition
By :
When writing a Terraform configuration, it is important to be able to validate the syntax of the configuration we are writing before executing it, or even before archiving it in a Git repository.
We will see in this recipe how, by using the Terraform binary, we can check the validity of Terraform configuration syntax.
For this recipe, we will start with the following Terraform configuration, which is written in a main.tf file:

Figure 6.6: Bad Terraform configuration
What we notice in the preceding code is that the declaration of the environment variable is missing.
The source code of this recipe is available here: https://github.com/PacktPublishing/Terraform-Cookbook-Second-Edition/tree/main/CHAP06/validate.
To validate our Terraform configuration syntax, perform the following steps:
terraform...