nerdexam
HashiCorp

TA-002-P · Question #93

Which of the following is not an action performed by terraform init?

The correct answer is A. Create a sample main.tf file. 'terraform init' prepares a working directory by downloading providers and modules but never creates configuration files like main.tf.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

Which of the following is not an action performed by terraform init?

Options

  • ACreate a sample main.tf file
  • BInitialize a configured backend
  • CRetrieve the source code for all referenced modules
  • DLoad required provider plugins

How the community answered

(24 responses)
  • A
    88% (21)
  • B
    4% (1)
  • C
    8% (2)

Why each option

'terraform init' prepares a working directory by downloading providers and modules but never creates configuration files like main.tf.

ACreate a sample main.tf fileCorrect

Creating sample or template configuration files such as main.tf is not a function of 'terraform init'; that responsibility belongs entirely to the developer or external scaffolding tools. The command is scoped to initializing the backend, downloading provider plugins, and fetching module source code needed to make the configuration functional. Generating files would risk overwriting existing user-authored configurations and is outside the command's design intent.

BInitialize a configured backend

Initializing a configured backend is a documented and primary action of 'terraform init', setting up remote state storage.

CRetrieve the source code for all referenced modules

Retrieving source code for all referenced modules is a documented action of 'terraform init', which downloads modules from registries or VCS sources.

DLoad required provider plugins

Loading required provider plugins is a documented action of 'terraform init', which downloads and installs the correct provider binaries into the working directory.

Concept tested: terraform init command actions and scope

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

Topics

#terraform init#CLI#initialization#backend configuration

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice