Skip to content

Commit

Permalink
Call terraform validate and terragrunt validate-inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
zackproser committed Aug 16, 2021
1 parent 61111ac commit 3d0371c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/terraform/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ func Validate(t testing.TestingT, options *Options) string {
return out
}

// ValidateInputs calls terragrunt validate and returns stdout/stderr.
func ValidateInputs(t testing.TestingT, options *Options) string {
out, err := ValidateInputsE(t, options)
require.NoError(t, err)
return out
}

// ValidateE calls terraform validate and returns stdout/stderr.
func ValidateE(t testing.TestingT, options *Options) (string, error) {
return RunTerraformCommandE(t, options, FormatArgs(options, "validate")...)
Expand Down Expand Up @@ -54,6 +61,5 @@ func InitAndValidateInputsE(t testing.TestingT, options *Options) (string, error
if _, err := InitE(t, options); err != nil {
return "", err
}
// JUST FOR TESTING / BENCHMARKING
return ValidateE(t, options)
return ValidateInputsE(t, options)
}
3 changes: 3 additions & 0 deletions modules/test-structure/test_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ func ValidateAllTerraformModules(t *go_test.T, opts *ValidationOptions) {
tfOpts := &terraform.Options{TerraformDir: testFolder}
if opts.FileType == TG {
tfOpts.TerraformBinary = "terragrunt"
// First call init and terraform validate
terraform.InitAndValidate(t, tfOpts)
// Next, call terragrunt validate-inputs which will catch mis-aligned inputs provided via Terragrunt
terraform.ValidateInputs(t, tfOpts)
} else if opts.FileType == TF {
terraform.InitAndValidate(t, tfOpts)
}
Expand Down

0 comments on commit 3d0371c

Please sign in to comment.