Terraform-Associate-004 practice question 6 of 35
terraform init retrieves and caches the configuration for all remote modules.
Full set: 360 questionsThe terraform init command is responsible for preparing a working directory for use with Terraform. One of its primary tasks is module installation. During this process, Terraform scans the configuration for any module blocks that reference remote sources (such as the Terraform Registry, Git repositories, or HTTP URLs). It then downloads the source code for these modules and stores them in a local subdirectory named .terraform/modules. This local copy serves as a cache, ensuring that subsequent commands like plan and apply have access to the complete configuration code.
The statement is a correct description of a core function of the terraform init command. Therefore, selecting "False" would be incorrect. If terraform init did not retrieve and cache remote modules, Terraform would be unable to interpret the full configuration, and commands like terraform plan or terraform apply would fail because they would lack the resource definitions contained within those modules.
1. HashiCorp Terraform Documentation, "Command: init": In the "Module Installation" section, the documentation states, "During init, the root module's configuration is searched for module blocks, and the source code for referenced modules is retrieved from the locations given in their source arguments... Terraform will download and cache the module in a subdirectory of the .terraform/modules directory in your working directory."
Source: HashiCorp, Terraform CLI Documentation, "Command: init", section "Module Installation". Retrieved from https://developer.hashicorp.com/terraform/cli/commands/init#module-installation.
2. HashiCorp Terraform Documentation, "Module Sources": This page details how modules are sourced and explicitly links this action to the init command. It states, "When you run terraform init, Terraform will read the source argument for each of your modules and download the module's files into a subdirectory of your .terraform/modules directory."
Source: HashiCorp, Terraform Language Documentation, "Module Sources". Retrieved from https://developer.hashicorp.com/terraform/language/modules/sources#module-sources.
Keep practicing
Take the free Terraform-Associate-004 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Terraform-Associate-004 practice questions
- Question 1You should run terraform fnt to rewrite all Terraform configurations within the current w…
- Question 2Module variable assignments are inherited from the parent module and you do not need to e…
- Question 3terraform validate confirms thesyntaxof Terraform files.
- Question 4Using the terraform state rm command against a resource will destroy it.
- Question 5Variables declared within a module are accessible outside of the module.
- Question 7terraform validate uses provider APIs to verify your infrastructure settings.
