Terraform Associate 2025 – 400 Free Practice Questions to Pass the Exam

Question: 1 / 400

As a member of the operations team, which provision is best to run a script on a virtual machine created by Terraform?

local-exec

remote-exec

The option to run a script on a virtual machine created by Terraform that is most suitable is remote-exec. This provisioner is specifically designed to execute commands or scripts on a remote machine after it has been created and is accessible via SSH or WinRM, depending on the environment.

When you use remote-exec, Terraform establishes a connection to the VM and can run scripts directly in that context, which is essential for configuring the machine as needed after its initial creation. This capability allows for greater flexibility, such as installing software, configuring services, or performing any number of tasks that must be executed in the context of the newly created VM.

Other options like local-exec are intended for running commands on the machine that is executing Terraform itself, rather than on the remote VM. User-data typically refers to a mechanism used in cloud-init or similar services to pass configuration scripts to instances at launch time, but it does not provide the same execution control as remote-exec. A provisioner is more of a category that encompasses both local-exec and remote-exec, but it does not precisely indicate which type is best suited for running scripts on a VM created by Terraform. Thus, remote-exec stands out as the most appropriate choice in this context.

Get further explanation with Examzify DeepDiveBeta

user-data

provisioner

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy