Avoid duplicating resources when applying templates

I’m using InfluxDB 2.0.4 and I want to describe specific resources (i.e. buckets and tasks) in templates in order to use an IaC approach. However, at least in the case of tasks, identical tasks with identical names are created each time I influx apply -f my_tasks.yaml. I’d expect influx apply would be smart enough to

  • figure out that if a task with the same name already exists, the creation of this task should be skipped or
  • see that such a task does not yet exist and add it.

However, I observe that even if identical tasks (i.e. same metadata.name and same spec in the YAML) already exist, influx apply creates new but identical ones with the same name and query.

Is there a better way to handle this duplication and avoid creating redundant tasks?