I have a Terraform module which I built that deploys two instances of the module to a separate region. In this module there is a key vault. I only want the key vault to be present in one of the two regions.
Here is my module:
resource "azurerm_resource_group" "test" {
name = "test"
location = "${var.location}"
}
resource "azurerm_key_vault" "keyvault" {
name = "keyvault"
}
Here is my main.tf
module "test_uswest2" {
source = "modules/test"
location = "westus2"
environment = "${var.environment}"
}
module "test_westcentralus" {
source = "modules/test"
location = "centralus"
environment = "${var.environment}"
}
I want to exclude the key vault in the second region/location.
Terraform doesn't seem to support if/else so I'm not sure what my options are.