TERRAFORM-ASSOCIATE-003 practice question 6 of 30

[Understand Terraform Basics and CLI] terraform init creates an example main.tf file in the current directory.

Full set: 226 questions
Answer options
A: True
B: False
Correct Answer:
[FALSE]
Explanation

The terraform init command is used to initialize a working directory that already contains Terraform configuration files (such as main.tf). Its primary purpose is to prepare the directory for other commands by performing three main actions: initializing the backend, downloading required provider plugins, and installing any referenced modules. The command reads existing configuration files to determine which providers and modules are needed; it does not create any example or boilerplate configuration files itself.

Why Incorrect

The statement is false because the creation of configuration files like main.tf is a prerequisite step that the user must perform before running terraform init. The command's role is to set up the environment based on pre-existing configuration, not to generate that configuration.

References

1. HashiCorp Terraform Documentation

"Command: init". The official documentation states

"The terraform init command initializes a working directory containing Terraform configuration files." The page details the command's actions as Backend Initialization

Child Module Installation

and Plugin Installation

none of which involve the creation of a main.tf file. The command's premise is that configuration files already exist.

Source: HashiCorp

Terraform CLI Documentation

"Command: init"

https://developer.hashicorp.com/terraform/cli/commands/init

2. HashiCorp Learn

"Get Started - Provision Infrastructure". In the official introductory tutorials

the workflow clearly separates file creation from initialization. In the "Write Configuration" step

the user is explicitly instructed to create a main.tf file. Only in the subsequent step

"Initialize the directory

" is the user directed to run terraform init. This procedural separation confirms that init does not create the file but rather acts upon it.

Source: HashiCorp Learn

Get Started with Terraform

"Provision Infrastructure"

https://developer.hashicorp.com/terraform/tutorials/aws-get-started/aws-build

Scroll to Top