Adding custom Pre and Post condition
In the previous recipe Manipulating Variables we learn that is possible to add condition validation inside variable definition.
In Terraform version 1.2 and newer versions, it’s possible to add custom validation directly in resources, modules, or data with pre-condition and post-condition.
These customs validation will allows Terraform to check some custom check during the execution of the terraform plan
: The precondition will be check just before the render of plan and the postcondition just after the render.
Let's get started!
Getting ready
To complete this recipe, we will start with this basic Terraform configuration:
resource "azurerm_virtual_network" "vnet" {
name = "vnet"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
address_space = [var.address_space]
}
This above Terraform configuration create an Azure...