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.
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 -targetwould try to apply changes to the resource if any are pending, but it won't force a rerun of alocal-execprovisioner without the resource first being tainted or otherwise marked for recreation. - C.
terraform validatechecks configuration syntax and semantics, but it does not modify the state or force resources to be rerun or recreated. - D.
terraform plan -targetwould show what changes would occur for that specific resource, but without tainting it, it wouldn't show a rerun of alocal-execprovisioner unless other changes to the resource triggered it.
Concept tested. Rerunning Terraform provisioners (taint)
Reference. https://developer.hashicorp.com/terraform/cli/commands/taint
Topics
Community Discussion
No community discussion yet for this question.