terraform init retrieves the source code for all referenced modules.
terraform init retrieves the source code for all referenced modules.
The terraform init command initializes a Terraform working directory by downloading any necessary plugins and the source code for modules specified in the configuration files. This ensures that the correct version of the module is available locally for Terraform to use when applying changes or planning. During init, Terraform searches for module blocks in the configuration and retrieves the source code from the locations specified in their source arguments.
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."
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
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.
https://www.terraform.io/cli/commands/init
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 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.
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.
If the referenced module is a local module then Terra-form init does not retrieve the module or its source
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.
That's False. Init is just for installing the providers source code, not the modules.
https://www.terraform.io/language/modules/sources Module source codes also
Terraform installs providers, initialises source code & modules etc at this stage