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?

Prepare for the HashiCorp Terraform Associate Exam. Utilize flashcards and multiple-choice questions with detailed hints and explanations. Boost your confidence and be ready for success!

Multiple Choice

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?

Explanation:
Tainting the resource is the right move because provisioners run when a resource is created or recreated. By tainting the null_resource.run_script, you mark it as needing recreation, so the next terraform apply will destroy and then recreate the resource, which automatically re-executes the local-exec provisioner. The other commands don’t trigger re-running provisioners. Validating checks syntax but doesn’t apply changes. Planning with a target shows potential changes but doesn’t apply or recreate anything. Applying with a target may change the resource only if there are actual changes to apply; without tainting, there’s nothing to recreate, so the provisioner wouldn’t run again.

Tainting the resource is the right move because provisioners run when a resource is created or recreated. By tainting the null_resource.run_script, you mark it as needing recreation, so the next terraform apply will destroy and then recreate the resource, which automatically re-executes the local-exec provisioner.

The other commands don’t trigger re-running provisioners. Validating checks syntax but doesn’t apply changes. Planning with a target shows potential changes but doesn’t apply or recreate anything. Applying with a target may change the resource only if there are actual changes to apply; without tainting, there’s nothing to recreate, so the provisioner wouldn’t run again.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy