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

Prepare for your Terraform Associate Exam with our engaging quiz. Test your knowledge with multiple choice questions and receive detailed explanations to enhance your understanding. Ace your exam with confidence!

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.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy