Closed wyardley closed 3 years ago
Hello
terraspec
has a --spec
param to specify the path to a different folder but it doesn't support glob pattern.
Regarding project defining multiple modules, keep in mind terraspec
doesn't manage the terraform init
phase. So your options are :
test/foo
dir with a main.tf
calling only module foo, test/bar/main.tf
calling only module bar,.... Each dir can embed its own spec
folder with assertions for the module. With this option, you need to manage yourself a mechanism to browse all test directories, run terraform init
and terraspec
from them.Does it help ?
Yes, I think that helps. In our existing validation step in CI, we do already run terraform init across everything, so, long term, it would still be useful to have functionality along these lines if there’s a way to do it.
Also, in the case where you want to test instantiating a module different ways, is it possible to just set nil in the tfvars for the parameters you don’t want to set (vs having directories with different .tf files)
In our existing validation step in CI, we do already run terraform init across everything, so, long term, it would still be useful to have functionality along these lines if there’s a way to do it.
If you already run terraform init in multiple folders, why not running terraspec the same way ?
Also, in the case where you want to test instantiating a module different ways, is it possible to just set nil in the tfvars for the parameters you don’t want to set (vs having directories with different .tf files)
Yes, you can set a variable to null
in tfvars file.
For a project with multiple modules in the same project (e.g.,
modules/foo
,modules/bar
,modules/baz/qux
), is there a way to have terraspec find all the specs and recurse over them, whether that's laid out likemodules/foo/spec
ortest/spec/modules/foo
? Will it take a glob pattern likeor similar?
Also, in the examples, it seems as if you can have multiple test cases using the same
.tf
files, but different tfvars. But what if you want to instantiate the module in a completely different way -- is there a suggested structure for handling that?