I'm creating a number of elasticsearch clusters in AWS using terraform. Each cluster can have a different number of instances. If there is one instance - there should be one AZ. If there are two instances - there should be two AZs. If I have one instance in my terraform aws\_elasticsearch\_domain resource, I set zone\_awareness\_enabled as false. The problem is that zone\_awareness\_config is not ignored as I would assume it should be. So if I have two AZs- I'd need to add the zone\_awareness\_config to the tf file. I'd have to manage two files.

This is the cluster\_config:

```
cluster_config {
      instance_type = "c5.large.elasticsearch"
      instance_count = var.es_instance_count
      dedicated_master_enabled = var.dedicated_master_enabled
      dedicated_master_count = var.es_instance_count
      zone_awareness_enabled = var.es_instance_count > 1 ? true : false
      zone_awareness_config {
        availability_zone_count = var.es_instance_count
      }
  }

```

The cluster\_config should work for 2 or 3 instances, but also for 1 instance in 1 AZ. But it doesn't. If I have 1 AZ - I have to remove the zone\_awareness\_config from the file.
How can I ignore the zone\_awareness\_config if I have 1 AZ?