Callum Hester
Callum Hester

Reputation: 67

Terraform how to skip argument for 1 workspace

Is it possible to skip 1 argument for 1 workspace in terraform?

resource "azurerm_application_gateway" "appgw" {
  name                = var.appgw
  resource_group_name = var.resource_group
  location            = var.location
  **zones = var.aks_zones**
  sku {
    name = var.app_gateway_sku
    tier = var.app_gateway_tier
  }   

I am setting a DR environment in a region where availability zones are not supported, so for the script to pass the "Zones" argument needs to be skipped for one workspace only. Is this possible?

Upvotes: 2

Views: 275

Answers (2)

Callum Hester
Callum Hester

Reputation: 67

To fix this, I added an availability_zone = "No-Zone" argument to my AppGW IP address block.

Upvotes: 1

Adil B
Adil B

Reputation: 16806

Since the azurerm_application_gateway resource's zones variable is Optional (source), you can set the default value for your aks_zones variable to null:

variable "aks_zones" {
  default = null
}

This way, you can skip specifying the aks_zones variable for your one workspace while setting a value for the other workspaces.

Upvotes: 0

Related Questions