nerdexam
HashiCorp

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.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

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)
  • A
    3% (1)
  • B
    8% (3)
  • C
    87% (33)
  • D
    3% (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.

AOn disk in the /tmp directory

Terraform typically does not use the `/tmp` directory for persistent module caching; it uses the project-specific `.terraform` directory.

BIn memory

Modules are cached on disk for persistence across Terraform runs, not solely in volatile memory.

COn disk in the .terraform sub-directoryCorrect

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.

DThey are not cached

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

#Terraform CLI#terraform init#Modules#Caching

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice