Terraform plan is giving the error : function call (function yamldecode) error

Please find the GitLab repo for the terraform scripts which we are using : https://gitlab.com/komati.udaykiran/gkewithterraform .

In terraform plan we are getting the below error in an all-in-one.YAML file for the elastic search ( which is present in the gitlab repo URL pinned above).

Error:

Error in function call on kubernetes.tf line 49, in locals: 49: resource_list = yamldecode(file("${path.module}/all-in-one.yaml")).items
|---------------- | path.module is “.”

Call to function “yamldecode” failed: on line 458, column 1: unexpected extra content after value.

Here we are setting up the GKE kubernetes cluster and when after setting it up with terraform scripts i am trying to set up the kubernetes Elastic Search over the GKE cluster with the kubectl external provider and getting the above mention error while running that above mentioned YAML file.

Any help and guidance will be really appreciated.

yaml

As far as I know, yamldecode only supports one YAML “document” per file. The --- notation indicates the start of a second document - you will need to split that out into a separate file to use with yamldecode.

1 Like

Do you really think that will be the case?
i am too not sure but let me surely try to execute your point by trying it for one documet per file. after that will let you know the status.
Thanks for the help @aareet Appreciated :slightly_smiling_face:

i tried that but still no luck ( i am getting the same error ) @aareet

Error:

apmservers.apm.k8s.elastic.co failed to create kubernetes rest client for update of resource: resource [apiextensions.k8s.io/v1beta1/CustomResourceDefinition] isn’t valid for cluster, check the APIVersion and Kind fields are valid

That looks like a different issue - what’s your cluster version? The minimum supported is 1.17

oh is this the case. the one that we are using is 1.15.12-gke.2.

@aareet are you sure it is the issue with that? as i m getting this error now when i tried with the this part :

resource “kubectl_manifest” “lb” {
yaml_body = file("${path.module}/tcp_loadbalancer.yaml")
}