After running terraform apply, the provisioner does not run. What is the most likely cause?
medium
A. The command syntax is incorrect
B. The provisioner block must be outside the resource block
C. Terraform does not support local-exec provisioners
D. The resource has no changes, so provisioner is not triggered
Solution
Step 1: Understand provisioner trigger conditions
Provisioners run only when the resource is created or replaced, not on every apply if no changes.
Step 2: Analyze the resource state
If the null_resource has no changes, Terraform skips running the provisioner.
Final Answer:
The resource has no changes, so provisioner is not triggered -> Option D
Quick Check:
Provisioners run only on resource changes = B [OK]
Hint: Provisioners run only on resource create or replace [OK]
Common Mistakes:
Assuming provisioners run every apply
Thinking local-exec syntax is wrong here
Placing provisioner block outside resource
5. You need to run a script on a VM after creation, but the script requires sensitive data and complex setup. Why is it better to avoid Terraform provisioners and what should you do instead?
hard
A. Avoid provisioners because they run before resource creation; run scripts manually instead
B. Avoid provisioners because they can leak sensitive data; use configuration management tools like Ansible
C. Use provisioners because they securely handle sensitive data automatically
D. Use provisioners because they guarantee idempotent script execution
Solution
Step 1: Identify risks with provisioners and sensitive data
Provisioners can expose sensitive data in logs and are not idempotent, risking security and reliability.
Step 2: Choose better alternatives
Using configuration management tools like Ansible or cloud-init handles complex setup securely and reliably outside Terraform.
Final Answer:
Avoid provisioners because they can leak sensitive data; use configuration management tools like Ansible -> Option B
Quick Check:
Provisioners risk data leaks; prefer config tools = C [OK]
Hint: Use config tools for sensitive setup, not provisioners [OK]
Common Mistakes:
Assuming provisioners handle sensitive data securely
Thinking provisioners run before resource creation
Believing provisioners guarantee idempotency
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.