Terraform | Ignore specific variable under `tag` attribute

Hello, I need help, I can not make an ignore to a variable which is under tag attribute


Here is my code:

   tags = merge(
     {
         "Name"  =  lookup(var.tags[0], "name","default")
     },
     lookup(var.tags[0], "optional", null)


   lifecycle {
     create_before_destroy = true
     ignore_changes        = [ tags ]
   }

So I need to ignore lookup(var.tags[0], "optional", null), and instead of ignoring one single variable, I’ve to ignore whole tags, please help me on this.


Here is the variable type

variable "tags"  {
   description = "The Tags"
   type        = list(object({
     name      = string
     optional  = optional(map(string))
   }))
   default     = null
}

I don’t know the exact syntax of what you’re try to do with the variable, but if the name of the tag is known and the value changes then you can ignore a specific tag as follows:

lifecycle {
  ignore_changes = [
    tags['tag-name'],
  ]
}

If the name of the tag changes then I’m sorry I don’t think I can help :slightly_smiling_face: