func DestroyTF()

in cli/pkg/lifecycle/tf_delete.go [28:51]


func DestroyTF(tfDir string) {
	tmpDir, err := os.MkdirTemp("", "tfinstall")
	if err != nil {
		log.Fatalf("error creating temp dir: %s", err)
	}
	defer os.RemoveAll(tmpDir)

	execPath, err := tfinstall.Find(context.Background(), tfinstall.ExactVersion("1.9.5", tmpDir))
	if err != nil {
		log.Fatalf("error locating Terraform binary: %s", err)
	}

	tf, err := tfexec.NewTerraform(tfDir, execPath)
	if err != nil {
		log.Fatalf("error running NewTerraform: %s", err)
	}

	tf.SetStdout(os.Stdout)

	err = tf.Destroy(context.Background(), tfexec.VarFile("../terraform.tfvars"))
	if err != nil {
		log.Fatalf("error running Destroy: %s", err)
	}
}