terraform resource being destroyed

Viewed 25

I am creating two opensearc resources through modules, except the second one is using a different version of the same module.

like this:

module "mymodule1" {
  source            = "gitsource.git"
  vpc_name          = var.vpc_name
  domain            = "domain1-name"
  shared_acc_cidr   = var.shared_acc_cidr
  es_version        = xxx
  es_instance_count = ttt
  es_instance_type  = "tx.xxx.elasticsearch"
  tags = merge(
    var.default_tags, var.map_tags, {

    }
  )
}

module "mymodule2" {
  count = var.vpc_name == "dev" ? 1 : 0
  source            = "gitsource.git?ref=v1.1.0"
  vpc_name          = var.vpc_name
  domain            = "domain2-name
  shared_acc_cidr   = concat(var.p2_vpn_cidr, [var.shared_acc_cidr])
  es_version        = xxx
  es_instance_count = ttt
  es_instance_type  = "tx.xxx.elasticsearch"
  tags = merge(
    var.default_tags, var.map_tags, {

    }
  )
}

what I find off is that everytime I change something in the TF the second resource (the one that uses the module tag) gets destroyed and recreated.

I wonder if it is due to the module versioning and TF thinks is a new resource? Because I am not changing anything, I am updating descriptions or variable values.

0 Answers
Related