nerdexam
HashiCorpHashiCorp

TA-002-P · Question #6

TA-002-P Question #6: Real Exam Question with Answer & Explanation

The correct answer is A: terraform taint null_resource.run_script. To force a local-exec provisioner within a null_resource to rerun, you must first taint the resource, marking it for recreation on the next apply.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

You run a local-exec provisioner in a null resource called null_resource.run_script and realize that you need to rerun the script. Which of the following commands would you use first?

Options

  • Aterraform taint null_resource.run_script
  • Bterraform apply -target=null_resource.run_script
  • Cterraform validate null_resource.run_script
  • Dterraform plan -target=null_resource.run_script

Explanation

To force a local-exec provisioner within a null_resource to rerun, you must first taint the resource, marking it for recreation on the next apply.

Common mistakes.

  • B. terraform apply -target would try to apply changes to the resource if any are pending, but it won't force a rerun of a local-exec provisioner without the resource first being tainted or otherwise marked for recreation.
  • C. terraform validate checks configuration syntax and semantics, but it does not modify the state or force resources to be rerun or recreated.
  • D. terraform plan -target would show what changes would occur for that specific resource, but without tainting it, it wouldn't show a rerun of a local-exec provisioner unless other changes to the resource triggered it.

Concept tested. Rerunning Terraform provisioners (taint)

Reference. https://developer.hashicorp.com/terraform/cli/commands/taint

Topics

#terraform taint#provisioners#null_resource#resource lifecycle

Community Discussion

No community discussion yet for this question.

Full TA-002-P PracticeBrowse All TA-002-P Questions