Testing and evaluating a Terraform expression
When we write a Terraform configuration that contains variables and expressions or uses a built-in Terraform function, it’s sometimes difficult to predict the result of this Terraform configuration before running the apply
command.
Fortunately, the Terraform CLI contains a feature that will allow us to evaluate Terraform code before applying changes.
In this recipe, we will see how to test and evaluate a Terraform expression.
Let’s get started!
Getting ready
To complete this recipe, we will use the following Terraform configuration that provisions Azure infrastructure:
https://github.com/PacktPublishing/Terraform-Cookbook-Second-Edition/tree/main/CHAP06/console
Here we use the azurerm
provider, but this recipe can be applied for any Terraform configuration.
In this Terraform configuration, we use several Terraform variables and expressions such as:
locals {
linux_web_app = toset([for...