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.
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)- A88% (21)
- B4% (1)
- C8% (2)
Why each option
'terraform init' prepares a working directory by downloading providers and modules but never creates configuration files like main.tf.
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.
Initializing a configured backend is a documented and primary action of 'terraform init', setting up remote state storage.
Retrieving source code for all referenced modules is a documented action of 'terraform init', which downloads modules from registries or VCS sources.
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
Community Discussion
No community discussion yet for this question.