title: Terratest multiple targets
body: <p>I am using terrates to test my terraform code.
  My code have 2 modules so I managed to configure terratest to use target option while configuring the terraformOptions and it creates both modules.</p>
  <p>However, when it comes to clean everything, it cleans only the last module using Defer.
  Here is my code.</p>
  <pre><code>    package test
  
  import (
      &quot;fmt&quot;
      &quot;os&quot;
      &quot;testing&quot;
  
      &quot;github.com/gruntwork-io/terratest/modules/terraform&quot;
  
      test_structure &quot;github.com/gruntwork-io/terratest/modules/test-structure&quot;
  )
  
  func configureTerraformOptions(t *testing.T, terraformDir string, tfModule string) (*terraform.Options) {
  
      awsRegion := os.Getenv(&quot;AWS_REGION&quot;)
  
      terraformOptions := &amp;terraform.Options{
  
          TerraformDir: terraformDir,
          Targets: []string{tfModule},
          Vars: map[string]interface{}{
              &quot;aws_region&quot;: awsRegion,
          },
      }
  
      return terraformOptions
  
  }
  
  func TestInfra(t *testing.T) {
      t.Parallel()
  
      terraformDir := test_structure.CopyTerraformFolderToTemp(t, &quot;../&quot;, &quot;tests/terraform&quot;)
  
      defer test_structure.RunTestStage(t, &quot;destroy&quot;, func() {
          terraformOptions := test_structure.LoadTerraformOptions(t, terraformDir)
          terraform.Destroy(t, terraformOptions)
  
      })
  
      test_structure.RunTestStage(t, &quot;setup&quot;, func() {
          terraformOptionsInfra := configureTerraformOptions(t, terraformDir, &quot;module.one&quot;)
          terraformOptionsConf := configureTerraformOptions(t, terraformDir, &quot;module.two&quot;)
  
          test_structure.SaveTerraformOptions(t, terraformDir, terraformOptionsInfra)
  
          test_structure.SaveTerraformOptions(t, terraformDir, terraformOptionsConf)
  
          terraform.InitAndApply(t, terraformOptionsInfra)
          terraform.InitAndApply(t, terraformOptionsConf)
      })
      test_structure.RunTestStage(t, &quot;validate&quot;, func() {
          terraformOptions := test_structure.LoadTerraformOptions(t, terraformDir)
          testHello(t, terraformOptions)
  
      })
  }
  
  func testHello(t *testing.T, terraformOptions *terraform.Options) {
     fmt.Printf(&quot;Hello&quot;)
  }
  </code></pre>
  <p>Is there any way to target like when I apply ?</p>
  <p>Thanks;</p>