https://developer.hashicorp.com/terraform/cli/commands/init#child-module-installation
"During init, the configuration is searched for module blocks, and the source code for referenced modules is retrieved from the locations given in their source arguments."
terraform init initializes a Terraform working directory by downloading any necessary plugins and modules specified in the configuration files. It doesn't retrieve the source code for all referenced modules directly. Instead, it initializes the modules based on the module configurations and retrieves their source code when Terraform needs to apply changes or perform other operations.
B. False
Terraform init does not automatically retrieve the source code for all referenced modules.
Here's a breakdown of what terraform init actually does:
Initializes the Terraform working directory.
Downloads and installs required providers.
Sets up the necessary infrastructure for working with Terraform.
To retrieve module source code, you'd use terraform get or a separate module download mechanism like Git or HTTP. The source argument within your Terraform configuration specifies the location of the module's source code, which terraform init then uses to download the code during the installation process.
B. False
terraform init does a lot of setup work, including initializing the backend, installing providers that are used in the configuration, and preparing the working directory for other commands. However, its role in handling modules is specific to initializing modules by downloading their source code if they are not already present locally and are referenced from remote sources. It doesn't retrieve the source code for modules that are already initialized or if the modules are defined locally (in the same repository and not requiring a download). So, while it does prepare modules for use, saying it retrieves the source code for "all" referenced modules might be misleading if interpreted to mean it re-downloads or updates modules already initialized without the -upgrade flag.
B. False
The statement is false. The terraform init command does not automatically retrieve the source code for all referenced modules in Terraform configuration. Instead, terraform init is used to initialize a Terraform working directory by downloading and installing the required providers and setting up the necessary infrastructure to work with Terraform.
The source code of the modules should be present locally in the working directory or in a remote repository specified in the Terraform configuration. To retrieve the modules, you need to use the terraform get command or set up a module download mechanism like Git or HTTP.
A. True. Terraform init retrieves the source code for all referenced modules. When Terraform init is run, it will automatically download the source code for any modules referenced in the configuration files. This ensures that the correct version of the module is available for use when Terraform applies changes to the infrastructure. The source code is then cached locally so that it can be used in future runs without having to re-download it. It's important to notice that this command also initializes the backend and sets the backend configuration if specified.
Yes, the terraform init command retrieves the source code for all referenced modules in a Terraform configuration. It does not download the source code for any unreferenced modules or plugins.
it will still retrieve it but would not cache it
tf docs: During init, the configuration is searched for module blocks, and the source code for referenced modules is retrieved from the locations given in their source arguments.
https://www.terraform.io/language/modules/sources
Terraform uses this during the module installation step of terraform init to download the source code to a directory on local disk so that other Terraform commands can use it. It is A
During init, the configuration is searched for module blocks, and the source code for referenced modules is retrieved from the locations given in their source arguments.
https://www.terraform.io/cli/commands/init
Terraform installs providers, initialises source code & modules etc at this stage
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
DevoteamAnalytix
Highly Voted 1 year, 6 months agoRealPro111
Most Recent 2 months, 2 weeks agoARBAR
7 months agoAjit18
8 months, 2 weeks agoGanesh
9 months, 2 weeks agopiezaS
1 year, 6 months agoZeppoonstream
1 year, 10 months agoInformationOverload
1 year, 10 months agoyogishrb2020
2 years, 1 month agoRVivek
2 years, 1 month agoitsVespucci
2 years agoomodara
2 years, 2 months agolordogre16
2 years, 2 months agoA_A_AB
2 years, 2 months agoRVivek
2 years, 1 month agodepal_dhir
2 years, 2 months ago