TA-002-P · Question #79
When you initialize Terraform, where does it cache modules from the public Terraform Module Registry?
The correct answer is C. On disk in the .terraform sub-directory. Terraform caches modules downloaded from the public Terraform Module Registry on disk in the hidden .terraform sub-directory within the root module directory during initialization. This local caching improves performance for subsequent operations.
Question
When you initialize Terraform, where does it cache modules from the public Terraform Module Registry?
Options
- AOn disk in the /tmp directory
- BIn memory
- COn disk in the .terraform sub-directory
- DThey are not cached
How the community answered
(38 responses)- A3% (1)
- B8% (3)
- C87% (33)
- D3% (1)
Why each option
Terraform caches modules downloaded from the public Terraform Module Registry on disk in the hidden .terraform sub-directory within the root module directory during initialization. This local caching improves performance for subsequent operations.
Terraform typically does not use the `/tmp` directory for persistent module caching; it uses the project-specific `.terraform` directory.
Modules are cached on disk for persistence across Terraform runs, not solely in volatile memory.
During `terraform init`, Terraform downloads and caches required modules in the `.terraform` subdirectory of the root module directory. This local caching mechanism ensures that modules are readily available for future operations without needing to re-download them, speeding up subsequent `terraform plan` and `terraform apply` commands.
Terraform explicitly caches modules to avoid repeated downloads and improve efficiency.
Concept tested: Terraform module caching location
Source: https://developer.hashicorp.com/terraform/language/modules/syntax#local-file-paths
Topics
Community Discussion
No community discussion yet for this question.