hashicorp / terraform-provider-helm

Terraform Helm provider
https://www.terraform.io/docs/providers/helm/
Mozilla Public License 2.0
999 stars 370 forks source link

Error: YAML parse error when install kubernetes-dashboard from helm provider 2.8.0 #1068

Closed Hoon9901 closed 1 year ago

Hoon9901 commented 1 year ago

Terraform, Provider, Kubernetes and Helm Versions

Terraform version: v1.3.7 
Provider version: 2.8.0 darwin_amd64
Kubernetes version: v1.20.15

Affected Resource(s)

Terraform Configuration Files

versions.tf

terraform {

  required_providers {
    helm = {
      source  = "hashicorp/helm"
      version = "~> 2.8.0"
    }
  }
}

main.tf


resource "kubernetes_namespace" "kubernetes-dashboard-namespace" {
  metadata {
    name = "kubernetes-dashboard"
  }
}

resource "helm_release" "kubernetes-dashboard" {
  name = "kubernetes-dashboard"
  chart = "kubernetes-dashboard"
  repository = "https://kubernetes.github.io/dashboard/"
  namespace = kubernetes_namespace.kubernetes-dashboard-namespace.metadata[0].name
  version = "6.0.0"
  set {
    name = "extraArgs"
    value = "\"{--token-ttl=0}\""
  }
}

resource "kubernetes_ingress" "kubernetes-dashboard-ingress" {
  metadata {
    name = helm_release.kubernetes-dashboard.name
    namespace = kubernetes_namespace.kubernetes-dashboard-namespace.metadata[0].name
    annotations = {
      "kubernetes.io/ingress.class": "nginx"
      "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS"
      "nginx.ingress.kubernetes.io/proxy-body-size": "1000000m"
    }
  }
  spec {
    tls {
      hosts = [
        "dashboard.k8s.${var.master_ip}.${var.ingress_domain}"
      ]
    }

    rule {
      host = "dashboard.k8s.${var.master_ip}.${var.ingress_domain}"
      http {
        path {
          path = "/"

          backend {
            service_name = "kubernetes-dashboard"
            service_port = "443"
          }
        }
      }
    }
  }
}

# Service Account
data "kubernetes_service_account" "admin-user" {
  depends_on = [
    helm_release.kubernetes-dashboard
  ]
  metadata {
    namespace = kubernetes_namespace.kubernetes-dashboard-namespace.metadata[0].name
    name = "admin-user"
  }
}

# ClusterRoleBinding 
resource "kubernetes_cluster_role_binding" "admin-user-crb" {
   depends_on = [
    data.kubernetes_service_account.admin-user
  ]
  metadata {
    name = "admin-user"
  }
  role_ref {
    api_group = "rbac.authorization.k8s.io"
    kind      = "ClusterRole"
    name      = "cluster-admin"
  }
  subject {
    kind      = "ServiceAccount"
    name      = "admin-user"
    namespace = kubernetes_namespace.kubernetes-dashboard-namespace.metadata[0].name
  }
}

# token
data "kubernetes_secret_v1" "kubernetes-dashboard-token" {
  metadata {
    name = "${data.kubernetes_service_account.admin-user.default_secret_name}"
    namespace = kubernetes_namespace.kubernetes-dashboard-namespace.metadata[0].name
  }
  binary_data = {
    "data.token" = ""
  }
}

Debug Output

trace terraform apply

module.kubernetes_dashboard.helm_release.kubernetes-dashboard: Creating...
2023-02-17T10:33:38.148+0900 [INFO]  Starting apply for module.kubernetes_dashboard.helm_release.kubernetes-dashboard
2023-02-17T10:33:38.148+0900 [DEBUG] module.kubernetes_dashboard.helm_release.kubernetes-dashboard: applying the planned Create change
2023-02-17T10:33:38.148+0900 [TRACE] GRPCProvider: ApplyResourceChange
2023-02-17T10:33:38.148+0900 [TRACE] provider.terraform-provider-helm_v2.8.0_x5: Received request: @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/tf5server/server.go:805 tf_provider_addr=provider tf_req_id=a1349bf1-44e8-6350-e142-1039f1aadccd tf_resource_type=helm_release @module=sdk.proto tf_proto_version=5.3 tf_rpc=ApplyResourceChange timestamp=2023-02-17T10:33:38.148+0900
2023-02-17T10:33:38.149+0900 [TRACE] provider.terraform-provider-helm_v2.8.0_x5: Sending request downstream: tf_provider_addr=provider tf_req_id=a1349bf1-44e8-6350-e142-1039f1aadccd tf_resource_type=helm_release @module=sdk.proto tf_proto_version=5.3 tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/tf5serverlogging/downstream_request.go:17 timestamp=2023-02-17T10:33:38.148+0900
2023-02-17T10:33:38.150+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:33:38 [DEBUG] setting computed for "metadata" from ComputedKeys: timestamp=2023-02-17T10:33:38.150+0900
2023-02-17T10:33:38.150+0900 [TRACE] provider.terraform-provider-helm_v2.8.0_x5: Calling downstream: @caller=github.com/hashicorp/terraform-plugin-sdk/v2@v2.22.0/helper/schema/resource.go:836 tf_provider_addr=provider tf_rpc=ApplyResourceChange @module=sdk.helper_schema tf_req_id=a1349bf1-44e8-6350-e142-1039f1aadccd tf_resource_type=helm_release timestamp=2023-02-17T10:33:38.150+0900
2023-02-17T10:33:38.150+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:33:38 [DEBUG] [resourceReleaseCreate: kubernetes-dashboard] Started: timestamp=2023-02-17T10:33:38.150+0900
2023-02-17T10:33:38.152+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:33:38 [DEBUG] [resourceReleaseCreate: kubernetes-dashboard] Getting helm configuration: timestamp=2023-02-17T10:33:38.150+0900
2023-02-17T10:33:38.152+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:33:38 [DEBUG] [INFO] GetHelmConfiguration start: timestamp=2023-02-17T10:33:38.150+0900
2023-02-17T10:33:38.152+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:33:38 [DEBUG] Using kubeconfig: ../../cluster/certification/kubeconfig3.yaml: timestamp=2023-02-17T10:33:38.150+0900
2023-02-17T10:33:38.152+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:33:38 [INFO] Successfully initialized kubernetes config: timestamp=2023-02-17T10:33:38.150+0900
2023-02-17T10:33:38.152+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:33:38 [DEBUG] [INFO] GetHelmConfiguration success: timestamp=2023-02-17T10:33:38.150+0900
2023-02-17T10:33:38.154+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:33:38 [DEBUG] [resourceReleaseCreate: kubernetes-dashboard] Getting chart: timestamp=2023-02-17T10:33:38.150+0900
2023-02-17T10:33:41.631+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.data.kubernetes_secret_v1.kubernetes-dashboard-token" is waiting for "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user"
2023-02-17T10:33:41.631+0900 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/kubernetes\"] (close)" is waiting for "module.kubernetes_dashboard.kubernetes_cluster_role_binding.admin-user-crb"
2023-02-17T10:33:41.631+0900 [TRACE] dag/walk: vertex "output.kuberentes_dashboard_token (expand)" is waiting for "module.kubernetes_dashboard.output.kubernetes-dashboard-token-value (expand)"
2023-02-17T10:33:41.631+0900 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/kubernetes\"] (close)"
2023-02-17T10:33:41.631+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.output.kubernetes-dashboard-token-value (expand)" is waiting for "module.kubernetes_dashboard.data.kubernetes_secret_v1.kubernetes-dashboard-token"
2023-02-17T10:33:41.631+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.kubernetes_cluster_role_binding.admin-user-crb" is waiting for "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user"
2023-02-17T10:33:41.631+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user" is waiting for "module.kubernetes_dashboard.helm_release.kubernetes-dashboard"
2023-02-17T10:33:41.631+0900 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/helm\"] (close)" is waiting for "module.kubernetes_dashboard.helm_release.kubernetes-dashboard"
2023-02-17T10:33:41.970+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.kubernetes_ingress.kubernetes-dashboard-ingress" is waiting for "module.kubernetes_dashboard.helm_release.kubernetes-dashboard"
2023-02-17T10:33:46.632+0900 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/kubernetes\"] (close)"
2023-02-17T10:33:46.632+0900 [TRACE] dag/walk: vertex "output.kuberentes_dashboard_token (expand)" is waiting for "module.kubernetes_dashboard.output.kubernetes-dashboard-token-value (expand)"
2023-02-17T10:33:46.632+0900 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/helm\"] (close)" is waiting for "module.kubernetes_dashboard.helm_release.kubernetes-dashboard"
2023-02-17T10:33:46.632+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.data.kubernetes_secret_v1.kubernetes-dashboard-token" is waiting for "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user"
2023-02-17T10:33:46.632+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user" is waiting for "module.kubernetes_dashboard.helm_release.kubernetes-dashboard"
2023-02-17T10:33:46.632+0900 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/kubernetes\"] (close)" is waiting for "module.kubernetes_dashboard.kubernetes_cluster_role_binding.admin-user-crb"
2023-02-17T10:33:46.632+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.kubernetes_cluster_role_binding.admin-user-crb" is waiting for "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user"
2023-02-17T10:33:46.632+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.output.kubernetes-dashboard-token-value (expand)" is waiting for "module.kubernetes_dashboard.data.kubernetes_secret_v1.kubernetes-dashboard-token"
2023-02-17T10:33:46.970+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.kubernetes_ingress.kubernetes-dashboard-ingress" is waiting for "module.kubernetes_dashboard.helm_release.kubernetes-dashboard"
module.kubernetes_dashboard.helm_release.kubernetes-dashboard: Still creating... [10s elapsed]

...

module.kubernetes_dashboard.helm_release.kubernetes-dashboard: Still creating... [1m10s elapsed]
2023-02-17T10:34:51.636+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.output.kubernetes-dashboard-token-value (expand)" is waiting for "module.kubernetes_dashboard.data.kubernetes_secret_v1.kubernetes-dashboard-token"
2023-02-17T10:34:51.636+0900 [TRACE] dag/walk: vertex "output.kuberentes_dashboard_token (expand)" is waiting for "module.kubernetes_dashboard.output.kubernetes-dashboard-token-value (expand)"
2023-02-17T10:34:51.637+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user" is waiting for "module.kubernetes_dashboard.helm_release.kubernetes-dashboard"
2023-02-17T10:34:51.637+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.kubernetes_cluster_role_binding.admin-user-crb" is waiting for "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user"
2023-02-17T10:34:51.637+0900 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/kubernetes\"] (close)"
2023-02-17T10:34:51.637+0900 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/helm\"] (close)" is waiting for "module.kubernetes_dashboard.helm_release.kubernetes-dashboard"
2023-02-17T10:34:51.637+0900 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/kubernetes\"] (close)" is waiting for "module.kubernetes_dashboard.kubernetes_cluster_role_binding.admin-user-crb"
2023-02-17T10:34:51.637+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.data.kubernetes_secret_v1.kubernetes-dashboard-token" is waiting for "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user"
2023-02-17T10:34:51.976+0900 [TRACE] dag/walk: vertex "module.kubernetes_dashboard.kubernetes_ingress.kubernetes-dashboard-ingress" is waiting for "module.kubernetes_dashboard.helm_release.kubernetes-dashboard"
2023-02-17T10:34:53.803+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:53 [DEBUG] [resourceReleaseCreate: kubernetes-dashboard] Preparing for installation: timestamp=2023-02-17T10:34:53.803+0900
2023-02-17T10:34:53.803+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:53 ---[ values.yaml ]-----------------------------------
extraArgs: '"{--token-ttl=0}"': timestamp=2023-02-17T10:34:53.803+0900
2023-02-17T10:34:53.803+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:53 [DEBUG] [resourceReleaseCreate: kubernetes-dashboard] Installing chart: timestamp=2023-02-17T10:34:53.803+0900
2023-02-17T10:34:54.503+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] [resourceReleaseExists: kubernetes-dashboard] Start: timestamp=2023-02-17T10:34:54.503+0900
2023-02-17T10:34:54.503+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] [INFO] GetHelmConfiguration start: timestamp=2023-02-17T10:34:54.503+0900
2023-02-17T10:34:54.503+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] Using kubeconfig: ../../cluster/certification/kubeconfig3.yaml: timestamp=2023-02-17T10:34:54.503+0900
2023-02-17T10:34:54.503+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [INFO] Successfully initialized kubernetes config: timestamp=2023-02-17T10:34:54.503+0900
2023-02-17T10:34:54.503+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] [INFO] GetHelmConfiguration success: timestamp=2023-02-17T10:34:54.503+0900
2023-02-17T10:34:54.503+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] kubernetes-dashboard getRelease wait for lock: timestamp=2023-02-17T10:34:54.503+0900
2023-02-17T10:34:54.503+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] kubernetes-dashboard getRelease got lock, started: timestamp=2023-02-17T10:34:54.503+0900
2023-02-17T10:34:54.503+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] kubernetes-dashboard getRelease post action created: timestamp=2023-02-17T10:34:54.503+0900
2023-02-17T10:34:54.576+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] kubernetes-dashboard getRelease post run: timestamp=2023-02-17T10:34:54.576+0900
2023-02-17T10:34:54.576+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] getRelease for kubernetes-dashboard errored: timestamp=2023-02-17T10:34:54.576+0900
2023-02-17T10:34:54.576+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] release: not found: timestamp=2023-02-17T10:34:54.576+0900
2023-02-17T10:34:54.576+0900 [INFO]  provider.terraform-provider-helm_v2.8.0_x5: 2023/02/17 10:34:54 [DEBUG] [resourceReleaseExists: kubernetes-dashboard] Done: timestamp=2023-02-17T10:34:54.576+0900
2023-02-17T10:34:54.576+0900 [TRACE] provider.terraform-provider-helm_v2.8.0_x5: Called downstream: @module=sdk.helper_schema tf_provider_addr=provider tf_resource_type=helm_release @caller=github.com/hashicorp/terraform-plugin-sdk/v2@v2.22.0/helper/schema/resource.go:838 tf_req_id=a1349bf1-44e8-6350-e142-1039f1aadccd tf_rpc=ApplyResourceChange timestamp=2023-02-17T10:34:54.576+0900
2023-02-17T10:34:54.576+0900 [TRACE] provider.terraform-provider-helm_v2.8.0_x5: Received downstream response: @module=sdk.proto tf_resource_type=helm_release tf_rpc=ApplyResourceChange tf_req_id=a1349bf1-44e8-6350-e142-1039f1aadccd @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/tf5serverlogging/downstream_request.go:37 diagnostic_error_count=1 diagnostic_warning_count=0 tf_proto_version=5.3 tf_provider_addr=provider tf_req_duration_ms=76430 timestamp=2023-02-17T10:34:54.576+0900
2023-02-17T10:34:54.576+0900 [ERROR] provider.terraform-provider-helm_v2.8.0_x5: Response contains error diagnostic: diagnostic_summary="YAML parse error on kubernetes-dashboard/templates/deployment.yaml: error converting YAML to JSON: yaml: line 66: could not find expected ':'" tf_req_id=a1349bf1-44e8-6350-e142-1039f1aadccd tf_rpc=ApplyResourceChange @module=sdk.proto diagnostic_detail= tf_provider_addr=provider tf_resource_type=helm_release @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_severity=ERROR tf_proto_version=5.3 timestamp=2023-02-17T10:34:54.576+0900
2023-02-17T10:34:54.576+0900 [TRACE] provider.terraform-provider-helm_v2.8.0_x5: Served request: tf_resource_type=helm_release tf_proto_version=5.3 tf_provider_addr=provider tf_req_id=a1349bf1-44e8-6350-e142-1039f1aadccd @caller=github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/tf5server/server.go:831 @module=sdk.proto tf_rpc=ApplyResourceChange timestamp=2023-02-17T10:34:54.576+0900
2023-02-17T10:34:54.576+0900 [TRACE] maybeTainted: module.kubernetes_dashboard.helm_release.kubernetes-dashboard encountered an error during creation, so it is now marked as tainted
2023-02-17T10:34:54.576+0900 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for module.kubernetes_dashboard.helm_release.kubernetes-dashboard
2023-02-17T10:34:54.576+0900 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for module.kubernetes_dashboard.helm_release.kubernetes-dashboard
2023-02-17T10:34:54.576+0900 [TRACE] evalApplyProvisioners: module.kubernetes_dashboard.helm_release.kubernetes-dashboard is tainted, so skipping provisioning
2023-02-17T10:34:54.576+0900 [TRACE] maybeTainted: module.kubernetes_dashboard.helm_release.kubernetes-dashboard was already tainted, so nothing to do
2023-02-17T10:34:54.576+0900 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for module.kubernetes_dashboard.helm_release.kubernetes-dashboard
2023-02-17T10:34:54.579+0900 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for module.kubernetes_dashboard.helm_release.kubernetes-dashboard
2023-02-17T10:34:54.579+0900 [TRACE] statemgr.Filesystem: have already backed up original terraform.tfstate to terraform.tfstate.backup on a previous write
2023-02-17T10:34:54.580+0900 [TRACE] statemgr.Filesystem: state has changed since last snapshot, so incrementing serial to 20
2023-02-17T10:34:54.580+0900 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2023-02-17T10:34:54.615+0900 [ERROR] vertex "module.kubernetes_dashboard.helm_release.kubernetes-dashboard" error: YAML parse error on kubernetes-dashboard/templates/deployment.yaml: error converting YAML to JSON: yaml: line 66: could not find expected ':'
2023-02-17T10:34:54.615+0900 [TRACE] vertex "module.kubernetes_dashboard.helm_release.kubernetes-dashboard": visit complete, with errors
2023-02-17T10:34:54.615+0900 [TRACE] dag/walk: upstream of "module.kubernetes_dashboard.data.kubernetes_service_account.admin-user" errored, so skipping
2023-02-17T10:34:54.615+0900 [TRACE] dag/walk: upstream of "module.kubernetes_dashboard.kubernetes_ingress.kubernetes-dashboard-ingress" errored, so skipping
2023-02-17T10:34:54.615+0900 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/hashicorp/helm\"] (close)" errored, so skipping
2023-02-17T10:34:54.615+0900 [TRACE] dag/walk: upstream of "module.kubernetes_dashboard.kubernetes_cluster_role_binding.admin-user-crb" errored, so skipping
2023-02-17T10:34:54.615+0900 [TRACE] dag/walk: upstream of "module.kubernetes_dashboard.data.kubernetes_secret_v1.kubernetes-dashboard-token" errored, so skipping
2023-02-17T10:34:54.615+0900 [TRACE] dag/walk: upstream of "module.kubernetes_dashboard.output.kubernetes-dashboard-token-value (expand)" errored, so skipping
2023-02-17T10:34:54.615+0900 [TRACE] dag/walk: upstream of "output.kuberentes_dashboard_token (expand)" errored, so skipping
2023-02-17T10:34:54.615+0900 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/hashicorp/kubernetes\"] (close)" errored, so skipping
2023-02-17T10:34:54.615+0900 [TRACE] dag/walk: upstream of "root" errored, so skipping
2023-02-17T10:34:54.615+0900 [TRACE] statemgr.Filesystem: have already backed up original terraform.tfstate to terraform.tfstate.backup on a previous write
2023-02-17T10:34:54.616+0900 [TRACE] statemgr.Filesystem: state has changed since last snapshot, so incrementing serial to 21
2023-02-17T10:34:54.616+0900 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
│ Warning: Applied changes may be incomplete
│
│ The plan was created with the -target option in effect, so some changes requested in the configuration may have been ignored and the output values may not be fully updated. Run the following command to verify that no other changes are pending:
│     terraform plan
│
│ Note that the -target option is not suitable for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an error message.
╵
╷
│ Error: YAML parse error on kubernetes-dashboard/templates/deployment.yaml: error converting YAML to JSON: yaml: line 66: could not find expected ':'
│
│   with module.kubernetes_dashboard.helm_release.kubernetes-dashboard,
│   on kubernetes_dashboard/main.tf line 9, in resource "helm_release" "kubernetes-dashboard":
│    9: resource "helm_release" "kubernetes-dashboard" {
│
╵
2023-02-17T10:34:54.689+0900 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2023-02-17T10:34:54.707+0900 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2023-02-17T10:34:54.708+0900 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-02-17T10:34:54.708+0900 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-02-17T10:34:54.709+0900 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/kubernetes/2.18.0/darwin_amd64/terraform-provider-kubernetes_v2.18.0_x5 pid=761
2023-02-17T10:34:54.709+0900 [DEBUG] provider: plugin exited
2023-02-17T10:34:54.713+0900 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/helm/2.8.0/darwin_amd64/terraform-provider-helm_v2.8.0_x5 pid=771
2023-02-17T10:34:54.713+0900 [DEBUG] provider: plugin exited

terraform apply

│ Error: YAML parse error on kubernetes-dashboard/templates/deployment.yaml: error converting YAML to JSON: yaml: line 66: could not find expected ':'
│
│   with module.kubernetes_dashboard.helm_release.kubernetes-dashboard,
│   on kubernetes_dashboard/main.tf line 9, in resource "helm_release" "kubernetes-dashboard":
│    9: resource "helm_release" "kubernetes-dashboard" {
│
╵

NOTE: In addition to Terraform debugging, please set HELM_DEBUG=1 to enable debugging info from helm.

Panic Output

Steps to Reproduce

  1. terraform apply

Expected Behavior

should deploy success without issues

Actual Behavior

Deployment is aborted due to the following YAML parsing errors: YAML parse error on kubernetes-dashboard/templates/deployment.yaml: error converting YAML to JSON: yaml: line 66: could not find expected ':'

Important Factoids

kubernetes-dashboard chart version has the same YAML parse error in 5.4.1 or 6.0.0 (latest) And it's the same problem when Helm provider's version is also used with 2.9.0

References

Community Note

Hoon9901 commented 1 year ago

The problem was caused by formatting token-ttl=0 incorrectly. helm provider had no problem and it was my mistake 😂

I solved it as follows

# Before
set {
    name = "extraArgs"
    value = "\"{--token-ttl=0}\""
 }

# After
 set {
    name = "extraArgs"
    value = "{--token-ttl=0}"
  }

Describe pod kubernetes-dashboard

  kubernetes-dashboard:
    Container ID:  docker://d4112be89500913371d8447761e41393611b47b52fabc66dbdd8f4ec378ed32d
    Image:         kubernetesui/dashboard:v2.5.1
    Image ID:      docker-pullable://kubernetesui/dashboard@sha256:cc746e7a0b1eec0db01cbabbb6386b23d7af97e79fa9e36bb883a95b7eb96fe2
    Port:          8443/TCP
    Host Port:     0/TCP
    Args:
      --namespace=kubernetes-dashboard
      --auto-generate-certificates
      --metrics-provider=none
      **--token-ttl=0**

terraform apply was successfully work.