forked from gruntwork-io/terratest
/
destroy.go
35 lines (28 loc) · 1.14 KB
/
destroy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package terraform
import (
"testing"
"github.com/stretchr/testify/require"
)
// Destroy runs terraform destroy with the given options and return stdout/stderr.
func Destroy(t *testing.T, options *Options) string {
out, err := DestroyE(t, options)
require.NoError(t, err)
return out
}
// TgDestroyAll runs terragrunt destroy with the given options and return stdout.
func TgDestroyAll(t *testing.T, options *Options) string {
out, err := TgDestroyAllE(t, options)
require.NoError(t, err)
return out
}
// DestroyE runs terraform destroy with the given options and return stdout/stderr.
func DestroyE(t *testing.T, options *Options) (string, error) {
return RunTerraformCommandE(t, options, FormatArgs(options, "destroy", "-auto-approve", "-input=false", "-lock=false")...)
}
// TgDestroyAllE runs terragrunt destroy with the given options and return stdout.
func TgDestroyAllE(t *testing.T, options *Options) (string, error) {
if options.TerraformBinary != "terragrunt" {
return "", TgInvalidBinary(options.TerraformBinary)
}
return RunTerraformCommandE(t, options, FormatArgs(options, "destroy-all", "-force", "-input=false", "-lock=false")...)
}