Courseiva
Understand Terraform basicsmediumMatchingObjective-mapped

TF-004 Understand Terraform basics Practice Question

Match each Terraform provisioner to its typical use case.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Copy files to the remote resource

Run a script on the machine running Terraform

Run a script on the remote resource

Configure resource using Chef

Configure resource using Puppet

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

file: Copies files or directories to the remote machine.

The correct matches are: file provisioner for copying files to the remote machine, remote-exec for running commands on the remote machine, and local-exec for running commands locally. Common confusions include swapping the roles of file and remote-exec.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • file: Copies files or directories to the remote machine.

    Why this is correct

    The `file` provisioner is specifically designed to securely transfer files or entire directories from the machine running Terraform to a newly created remote resource. It utilizes the connection details established for the resource, such as SSH or WinRM, to upload content, making it ideal for distributing configuration files or initial setup scripts. This ensures necessary data is present on the target system before other operations commence.

  • remote-exec: Runs commands on the remote resource using SSH or WinRM.

    Why this is correct

    The `remote-exec` provisioner executes arbitrary commands or scripts directly on the remote resource after it has been provisioned. It leverages established connection protocols like SSH for Linux/Unix systems or WinRM for Windows, allowing for post-creation setup tasks such as installing software packages or configuring services. This is crucial for bootstrapping instances with specific runtime requirements.

  • local-exec: Runs a script locally on the machine running Terraform.

    Why this is correct

    The `local-exec` provisioner executes commands or scripts on the local machine where the `terraform apply` command is being run, not on the remote infrastructure. This provisioner is typically used for tasks that need to interact with the local environment, such as generating configuration files, triggering local notifications, or running post-provisioning cleanup scripts. It operates independently of the remote resource's connection.

  • file: Runs commands on the remote resource.

    Why it's wrong here

    This statement is incorrect because the `file` provisioner's sole purpose is to transfer files or directories to a remote machine, not to execute commands on it. Its functionality is limited to copying data from a source path to a destination path on the target resource. Running commands remotely is the specific responsibility of the `remote-exec` provisioner, which is designed for command execution via SSH or WinRM.

  • remote-exec: Copies files to the local machine.

    Why it's wrong here

    This statement is incorrect as the `remote-exec` provisioner is designed to execute commands *on* the remote resource, not to facilitate file transfers *from* the remote resource *to* the local machine. While a remote command could theoretically initiate a download, `remote-exec` lacks native capabilities for secure, managed file retrieval to the Terraform runner. The `file` provisioner handles file transfers, but primarily for uploading to the remote machine.

About these practice questions

Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.