terratest: modules/terraform/var-file.go:142:8: undefined: hcl.Decode

Latest release is causing an error:

vendor/github.com/gruntwork-io/terratest/modules/terraform/var-file.go:142:8: undefined: hcl.Decode
FAIL	git.*******.com/mongodbatlas-tf/terratest/mongodbatlas-cluster [build failed]
FAIL

Exited with code exit status 2

https://github.com/gruntwork-io/terratest/blob/88ba3f070a939aca8351eae616a3c899bfe28b91/modules/terraform/var-file.go#L142

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 16 (6 by maintainers)

Most upvoted comments

I think the root of the issue is dep is trying to pull v2 of hcl while the go mod of the terratest library explicitly referenes v1, so dep isnt respecting the libraries required version

As WafflesMcDuff mentioned, use

go mod init

instead of

dep init

I was able to fix my new issue with GO111MODULE=on as per https://github.com/hashicorp/hcl/issues/371 so your update to terratest resolved my problems. Thank you.

This is indeed a bug as we should be using hclv2. Will work on updating the library function to use hcl v2 asap.

Apparently this version breaks compatibility with go dep. Had to switch from dep init && dep ensure -vendor-only to go mod init git.rockfin.com/mongodbtatlas-tf && go mod vendor