warrensbox/terraform-switcher

Any content in terragrunt.hcl other than "terraform_version_constraint" causes tfswitch to error

Closed this issue · 7 comments

Since this morning the following snippet:

terragrunt_version_constraint = "= 0.36.2"
terraform_version_constraint = "= 0.14.0"

Causes this output:

tfswitch --log-level=DEBUG
12:10:34.729 INFO [terragrunt.go:20,GetVersionFromTerragrunt] Reading configuration from "/redacted/terragrunt.hcl"  
12:10:34.729 FATAL [parameters.go:70,GetParameters] Error parsing configuration file: "could not decode body of HCL file \"/redacted/terragrunt.hcl\""  

However running like so:

terraform_version_constraint = "= 0.14.0"

Works as expected:

tfswitch --log-level=DEBUG                                                              ─╯
12:09:11.331 INFO [terragrunt.go:20,GetVersionFromTerragrunt] Reading configuration from "/redacted/terragrunt.hcl"  
12:09:11.331 DEBUG [list_versions.go:19,getTFList] Get list of terraform versions  
12:09:11.420 INFO [semver.go:14,GetSemver] Reading required version from constraint: "= 0.14.0"  
12:09:11.421 INFO [semver.go:42,SemVerParser] Matched version: "0.14.0"  
12:09:11.421 INFO [install.go:257,installableBinLocation] Installing terraform at "/home/redacted/bin"  
12:09:11.421 INFO [install.go:307,InstallVersion] Switched terraform to version "0.14.0" 

I've seen similar issues here this morning but they seem to be different outputs

Sorry I forgot to specify this is using a .hcl file not a .tf to configure versions

For now as a workaround I have:

  1. Downgraded to version 1.0.2 to avoid this issue
  2. Used the install script from commit 6950928 as the latest install script throws a 404 referencing older versions due to the syntax change

The line that throws the error:

return params, fmt.Errorf("could not decode body of HCL file %q", filePath)

Note that this doesn't actually output the error so I can't fix whatever is allegedly wrong with my file

The PR #264 could probably adress this issue. Unfortunately (due to lack of activity here) the PR was never finished and is outdated.
Personally i am struggling with implementing the terragrunt parser so any help with that is very welcome.

For now as a workaround I have:

  1. Downgraded to version 1.0.2 to avoid this issue
  2. Used the install script from commit 6950928 as the latest install script throws a 404 referencing older versions due to the syntax change

FYI: #405

The PR #264 could probably adress this issue. Unfortunately (due to lack of activity here) the PR was never finished and is outdated. Personally i am struggling with implementing the terragrunt parser so any help with that is very welcome.

I will see what I can do.

@MatrixCrawler Do you know if #264 resolves this issue? I haven't had the chance to test this yet

@warrensbox #409 will fix that definitely. in regards of #264 i am unsure