B. The command attribute is invalid for remote-exec
C. remote-exec provisioner requires a local script file
D. Missing connection block to specify how to connect to the resource
Solution
Step 1: Check remote-exec requirements
remote-exec provisioner needs a connection block to connect to the resource (SSH or WinRM).
Step 2: Identify missing connection block
The snippet lacks a connection block, causing Terraform to error because it cannot connect to run the command.
Final Answer:
Missing connection block to specify how to connect to the resource -> Option D
Quick Check:
remote-exec needs connection block = C [OK]
Hint: Always add connection block for remote-exec provisioners [OK]
Common Mistakes:
Assuming command attribute is invalid
Thinking sudo commands are disallowed
Believing remote-exec runs local scripts only
5. You want to install software on a new VM after Terraform creates it. Which approach best uses provisioners to do this reliably?
hard
A. Use a remote-exec provisioner with a connection block to run installation commands after creation
B. Use a local-exec provisioner to run installation commands on your local machine
C. Run installation commands manually after Terraform finishes
D. Use a provisioner without connection block to run commands remotely
Solution
Step 1: Identify provisioner type for remote VM configuration
remote-exec provisioner runs commands on the remote VM after creation using a connection block.
Step 2: Evaluate options for reliability
Using remote-exec with connection block automates installation reliably; local-exec runs locally, manual runs are error-prone, and missing connection causes failure.
Final Answer:
Use a remote-exec provisioner with a connection block to run installation commands after creation -> Option A