<p>Our current Production Elasticsearch cluster for logs collection is manually managed and runs on AWS.
I'm creating the same cluster using ECK deployed with Helm under Terraform.
I was able to get all the features replicated (S3 repo for snapshots, ingest pipelines, index templates, etc) and deployed, so, first deployment is perfectly working.
But when I tried to update the cluster (changing the ES version from 8.3.2 to 8.5.2) I get this error:</p>
<pre><code>│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to kubernetes_manifest.elasticsearch_deploy, provider &quot;provider\[&quot;registry.terraform.io/hashicorp/kubernetes&quot;\]&quot; produced an unexpected new
│ value: .object: wrong final value type: attribute &quot;spec&quot;: attribute &quot;nodeSets&quot;: tuple required.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
</code></pre>
<p>I stripped down my elasticsearch and kibana manifests to try to isolate the problem.
Again, I previously deployed the eck operator with its helm chart: it works, because the first deployment of the cluster is flawless.</p>
<p>I have in my main.tf:</p>
<pre><code>resource &quot;kubernetes_manifest&quot; &quot;elasticsearch_deploy&quot; {
  field_manager {
    force_conflicts = true
  }
  computed_fields = \[&quot;metadata.labels&quot;, &quot;metadata.annotations&quot;, &quot;spec.finalizers&quot;, &quot;spec.nodeSets&quot;, &quot;status&quot;\]
  manifest = yamldecode(templatefile(&quot;config/elasticsearch.yaml&quot;, {
    version                    = var.elastic_stack_version
    nodes                      = var.logging_elasticsearch_nodes_count
    cluster_name               = local.cluster_name
  }))
}
</code></pre>
<pre><code>resource &quot;kubernetes_manifest&quot; &quot;kibana_deploy&quot; {
  field_manager {
    force_conflicts = true
  }
  depends_on      = \[kubernetes_manifest.elasticsearch_deploy\]
  computed_fields = \[&quot;metadata.labels&quot;, &quot;metadata.annotations&quot;, &quot;spec.finalizers&quot;, &quot;spec.nodeSets&quot;, &quot;status&quot;\]
  manifest = yamldecode(templatefile(&quot;config/kibana.yaml&quot;, {
    version                    = var.elastic_stack_version
    cluster_name               = local.cluster_name
    namespace                  = local.stack_namespace
  }))
}
</code></pre>
<p>and my manifests are:</p>
<pre><code>apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  annotations:
    eck.k8s.elastic.co/downward-node-labels: &quot;topology.kubernetes.io/zone&quot;
  name: ${cluster_name}
  namespace: ${namespace}
spec:
  version: ${version}
  volumeClaimDeletePolicy: DeleteOnScaledownAndClusterDeletion
  monitoring:
    metrics:
      elasticsearchRefs:
      - name: ${cluster_name}
    logs:
      elasticsearchRefs:
      - name: ${cluster_name}
  nodeSets:
    - name: logging-nodes
    count: ${nodes}
    config:
      node.store.allow_mmap: false]]
</code></pre>
<pre><code>apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
  name: ${cluster_name}
  namespace: ${namespace}
spec:
  version: ${version}
  count: 1
  elasticsearchRef:
    name: ${cluster_name}
  monitoring:
    metrics:
      elasticsearchRefs:
        - name: ${cluster_name}
    logs:
      elasticsearchRefs:
        - name: ${cluster_name}
  podTemplate:
    metadata:
      labels:
        stack_name: ${stack_name}
        stack_repository: ${stack_repository}
    spec:
      serviceAccountName: ${service_account}
      containers:
        - name: kibana
          resources:
            limits:
              memory: 1Gi
              cpu: &quot;1&quot;
</code></pre>
<p>When I change the version, testing a cluster upgrade (e.g. going from 8.3.2 to 8.5.2), I get the error mentioned at the beginning of this post.
Is it a eck operator bug or I'm doing something wrong?
Do I need to add some other entity in the 'computed_fields' and remove 'force_conflicts'?</p>

Roberto D'Arco
<p>In the end, a colleague of mine found that indeed you have to add the whole &quot;spec&quot; to the computed_fields, like this:</p>
<pre><code>resource &quot;kubernetes_manifest&quot; &quot;elasticsearch_deploy&quot; {
  field_manager {
    force_conflicts = true
  }
  computed_fields = [&quot;metadata.labels&quot;, &quot;metadata.annotations&quot;, &quot;spec&quot;, &quot;status&quot;]
  manifest = yamldecode(templatefile(&quot;config/elasticsearch.yaml&quot;, {
    version                    = var.elastic_stack_version
    nodes                      = var.logging_elasticsearch_nodes_count
    cluster_name               = local.cluster_name
  }))
}
</code></pre>
<p>This way I got a proper cluster upgrade, without full cluster restart.</p>
<p>Underlying reason: the eck operator makes changes to the spec section. Even if you just do a terraform apply without any changes (and &quot;spec&quot; is not added to the computed_fields), terraform will find that something has changed and will perform an update.</p>
