Tried to run terratest over terraform file which invokes a aws instance and host a static website but post running this terratest module, it gives an undefined error for destroy function.
Terratest code:
`package test
import (
"fmt"
http_helper "github.com/gruntwork-io/terratest/modules/http-helper"
"github.com/gruntwork-io/terratest/modules/terraform"
"testing"
"time"
)
func TestTerraformHelloWorldExample(t *testing.T) {
t.Parallel()
// Construct the terraform options with default retryable errors to handle the most common
// retryable errors in terraform testing.
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
// Set the path to the Terraform code that will be tested.
TerraformDir: "../project-3/webserver",
})
terraform.InitAndApply(t, terraformOptions)
defer terraform.Destory(t, terraformOptions)
publicIp := terraform.Output(t, terraformOptions, "public_ip")
url := fmt.Sprintf("http://%s:8080", publicIp)
http_helper.HttpGetWithRetry(t, url, nil, 200, "I have made a Terraform module", 30, 5*time.Second)
}
`
~~~~~~~~~~~~
Output when I ran the test :
> go test webserver_test.go
# command-line-arguments [command-line-arguments.test]
./webserver_test.go:23:18: undefined: terraform.Destory
FAIL command-line-arguments [build failed]
FAIL
Tried to figure out why this is an issue but not able to get root cause. Could someone please help.
I did check the documentation and couple of tutorial video but didn't get much insight on the issue.
Seems a typo, so try:
instead of
See https://github.com/gruntwork-io/terratest/blob/e1570b571f726e7d2389b059519101a345b442d6/modules/terraform/destroy.go#L9