Creating Terraform Conditional resource based on mapped key.

Let’s create a conditional resource in Terraform based on a mapped key. Following post used for reference:

Start with a map data structure in our variable.tfvars:

Create a conditional azurerm_network_interface_backend_address_pool_assocation resource based on the value of the “docker_role” key in the above map. The lookup used in the logic below will only return true if the value is “swam-worker”. This resource block can be placed in any terraform file within the project.

Leave a Comment

Your email address will not be published. Required fields are marked *