gruntwork-io / terratest

Terratest is a Go library that makes it easier to write automated tests for your infrastructure code.
https://terratest.gruntwork.io/
Apache License 2.0
7.39k stars 1.32k forks source link

ValidateAllTerraformModules has a number of issues #1374

Closed brikis98 closed 5 months ago

brikis98 commented 7 months ago
  1. The ValidateAllTerraformModules function doesn't work on all repo structures. In particular, it calls runValidateOnAllTerraformModules under the hood, which tries to find the "git root" through a 100% hard-coded path of "go two folders up": filepath.Abs(filepath.Join(cwd, "../../")). This does not work for any Terraform code that isn't exactly two folders from the Git root! In fact, in a repo I tried this on, the code was just one folder down, and two folders up was a folder with ~100GB of code, so when this function then tried to copy all this to temp, it would hang. This code should use git.GetRepoRoot instead.
  2. (Minor) The ValidateAllTerraformModules method is in the test_structure package. Since this is a function for validating Terraform, it should be in the terraform package.