terraform-provider-kubectl: Error: Provider produced inconsistent final plan

Plan showed:

  # kubectl_manifest.argocd_bootstrap will be updated in-place
  ~ resource "kubectl_manifest" "argocd_bootstrap" ***
        id                      = "/apis/argoproj.io/v1alpha1/namespaces/argocd/applications/bootstrap"
        name                    = "bootstrap"
      ~ yaml_body               = (sensitive value)
        # (13 unchanged attributes hidden)
    ***

Apply:

Error: Provider produced inconsistent final plan

When expanding the plan for kubectl_manifest.argocd_bootstrap to include new
values learned so far during apply, provider
"registry.terraform.io/gavinbunney/kubectl" produced an invalid new value for
.yaml_body_parsed: was cty.StringVal("apiVersion: argoproj.io/v1alpha1\nkind:
Application\nmetadata:\n  name: bootstrap\n  namespace: argocd\nspec:\n
destination:\n    namespace: default\n    server:
https://kubernetes.default.svc\n  project: default\n  source:\n    helm:\n
valueFiles:\n      - values.yaml\n    path: helm/charts/bootstrap\n
repoURL:
https://github.com/company/project.git\n
targetRevision: main\n  syncPolicy:\n    automated: ***\n"), but now
cty.StringVal("apiVersion: argoproj.io/v1alpha1\nkind:
Application\nmetadata:\n  name: bootstrap\n  namespace: argocd\nspec:\n
destination:\n    namespace: default\n    server:
https://kubernetes.default.svc\n  project: default\n  source:\n    helm:\n
parameters:\n      - name: argocd.namespace\n        value: argocd\n      -
name: ingress_nginx.namespace\n        value: ingress-nginx\n      - name:
ingress_nginx.controller.service.annotations.service\\.beta\\.kubernetes\\.io/azure-dns-label-name\n
value: my-dns\n      - name:
ingress_nginx.controller.service.loadBalancerIP\n        value:
1.2.3.4\n      - name: ingress_nginx.controller.autoscaling.enabled\n
value: \"true\"\n      - name:
ingress_nginx.controller.autoscaling.min_replicas\n        value: \"2\"\n
valueFiles:\n      - values.yaml\n    path: helm/charts/bootstrap\n
repoURL:
https://github.com/company/project.git\n
targetRevision: main\n  syncPolicy:\n    automated: ***\n").

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

The plan is incorrect. The manifest has changes, which seems to be detected during apply which is causing the inconsistent final plan error.

Any ideas why this is happening?

I changed one letter in the manifest afterwards and ran it again, and the plan picked up all the changes which were successfully applied. Plan:

Terraform will perform the following actions:

  # kubectl_manifest.argocd_bootstrap will be updated in-place
  ~ resource "kubectl_manifest" "argocd_bootstrap" ***
        id                      = "/apis/argoproj.io/v1alpha1/namespaces/argocd/applications/bootstrap"
        name                    = "bootstrap"
      ~ yaml_body               = (sensitive value)
      ~ yaml_body_parsed        = <<-EOT
            apiVersion: argoproj.io/v1alpha1
            kind: Application
            metadata:
              name: bootstrap
              namespace: argocd
            spec:
              destination:
                namespace: default
                server: https://kubernetes.default.svc
              project: default
              source:
                helm:
          +       parameters:
          +       - name: argocd.namespace
          +         value: argocd
          +       - name: ingress_nginx.namespace
          +         value: ingress-nginx
          +       - name: ingress_nginx.controller.service.annotations.service\.beta\.kubernetes\.io/azure-dns-label-name
          +         value: my-dns
          +       - name: ingress_nginx.controller.service.loadBalancerIP
          +         value: 1.2.3.4
          +       - name: ingress_nginx.controller.autoscaling.enabled
          +         value: "true"
          +       - name: ingress_nginx.controller.autoscaling.minReplicas
          +         value: "2"
                  valueFiles:
                  - values.yaml
                path: helm/charts/bootstrap
                repoURL: https://github.com/company/project.git
                targetRevision: main
              syncPolicy:
                automated: ***
        EOT
        # (12 unchanged attributes hidden)
    ***

Plan: 0 to add, 1 to change, 0 to destroy.

Apply:

kubectl_manifest.argocd_bootstrap: Modifying... [id=/apis/argoproj.io/v1alpha1/namespaces/argocd/applications/bootstrap]
kubectl_manifest.argocd_bootstrap: Modifications complete after 0s [id=/apis/argoproj.io/v1alpha1/namespaces/argocd/applications/bootstrap]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

In the first run, I did upgrade the Kubernetes cluster at the same time. Not sure if that is related somehow. During plan:

  # azurerm_kubernetes_cluster.cluster1 will be updated in-place
  ~ resource "azurerm_kubernetes_cluster" "cluster1" ***
        id                              = "/subscriptions/abc123/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1"
      ~ kubernetes_version              = "1.18.14" -> "1.19.7"
        name                            = "cluster1"
        tags                            = ***
            "environment" = "dev"
        ***
        # (15 unchanged attributes hidden)



      ~ default_node_pool ***
            name                   = "default"
          ~ orchestrator_version   = "1.18.14" -> "1.19.7"
            tags                   = ***
            # (14 unchanged attributes hidden)
        ***



        # (5 unchanged blocks hidden)
    ***

gavinbunney/kubectl v1.10.0 hashicorp/azurerm v2.46.1 terraform_version: 0.14.5

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 16
  • Comments: 17

Most upvoted comments

creating the resource using the templatefile seems to be working fine.

resource “kubectl_manifest” “argocd_apps” { for_each = XXXXX yaml_body = templatefile(“${path.module}/manifests/apps.yaml”, { }) wait = “true” }

I’ve been looking at this for a while now its the customdiff for sure. I commented out this line and recompiled. Everything works from here but i think this then doesnt provide a “changed” count.

In the example code they do not use “SetNew” at all, anybody know how to fix this? https://www.terraform.io/docs/extend/resources/customizing-differences.html