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