Skip to content

002 · Domain 6: Advanced Module Usage and Registry Practices · 10% of the exam

Task 6.3: Use the Terraform registry to build or update a configuration

Consuming registry modules well: source addresses, version constraints, the standard module structure, private registry hosts and credentials in the CLI configuration file.

Study it

  • Registry modules: sources, versions and private registries

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.

Question 1 · choose 1

A team publishes its network module to the organization's private registry as app.terraform.io/acme/network/aws. The repository has an examples/basic directory that other teams copy into their own repositories. How should the module block in examples/basic/main.tf set source?

  1. Asource = "../../", pointing the example at the code in the same commit
  2. Bsource = "app.terraform.io/acme/network/aws" with a version constraint
  3. Csource = "./modules/network", the nested-module path inside the repository
  4. DCopy the module's resources into the example instead of calling it
Show the answer and why
  • Asource = "../../", pointing the example at the code in the same commit

    Incorrect

    Examples are copied into other repositories, where a relative path points nowhere, so HashiCorp recommends the external address.

  • Bsource = "app.terraform.io/acme/network/aws" with a version constraint

    Correct

    Module blocks in examples should use the address an external caller would use, so copied examples work unchanged.

  • Csource = "./modules/network", the nested-module path inside the repository

    Incorrect

    That path only resolves inside this repository; a copied example would not find it.

  • DCopy the module's resources into the example instead of calling it

    Incorrect

    An example should show how to call the module, not duplicate its resources.

Examples are meant to be copied into other repositories, so the standard module structure has their module blocks use the address an external caller would use.

Question 2 · choose 1

A registry module has nested modules under modules/. One has a README.md and one does not. How does the standard module structure treat the one without?

  1. AAs an internal module, not meant for outside use
  2. BAs invalid, as the registry rejects the module
  3. CAs the module's main entry point
  4. DAs an example to copy
Show the answer and why
  • AAs an internal module, not meant for outside use

    Correct

    Nested modules with a README.md are usable by external users; without one, a nested module is considered internal.

  • BAs invalid, as the registry rejects the module

    Incorrect

    Missing nested READMEs only change how the module is classified.

  • CAs the module's main entry point

    Incorrect

    The root of the repository is the primary entry point.

  • DAs an example to copy

    Incorrect

    Examples live under examples/.

Add a README.md to any nested module that callers are meant to use directly.

Question 3 · choose 1

The root of a published module calls its own nested module in modules/cluster. What should that module call reference?

  1. AThe registry address of the module plus //modules/cluster
  2. BA git URL pinned to the current tag
  3. Csource = "./modules/cluster"
  4. DAn absolute path on the build agent
Show the answer and why
  • AThe registry address of the module plus //modules/cluster

    Incorrect

    The structure guide says calls to nested modules use relative paths.

  • BA git URL pinned to the current tag

    Incorrect

    That would fetch a second copy of the package.

  • Csource = "./modules/cluster"

    Correct

    Calls from the root to nested modules should use relative paths so they come from the same package.

  • DAn absolute path on the build agent

    Incorrect

    Absolute paths break for every other caller.

With a relative path, Terraform treats the nested module as part of the same package instead of downloading it again.

Question 4 · choose 1

An engineer searching the public registry wants only modules that HashiCorp has reviewed for stability and compatibility. What should they use?

  1. ASort the results by download count
  2. BThe Partner filter in search results
  3. CUse any module under the hashicorp namespace
  4. DSearch for the word verified in descriptions
Show the answer and why
  • ASort the results by download count

    Incorrect

    Popularity is not a review.

  • BThe Partner filter in search results

    Correct

    The Partner filter limits results to partner modules, which HashiCorp reviews for stability and compatibility.

  • CUse any module under the hashicorp namespace

    Incorrect

    Namespace alone is not the documented filter.

  • DSearch for the word verified in descriptions

    Incorrect

    Description text is written by authors.

Still pin a version constraint for every registry module you adopt.

Question 5 · choose 1

Developers search the HCP Terraform private registry for "postgres" but do not find a module whose README discusses PostgreSQL at length. Why?

  1. APrivate modules are hidden from search
  2. BSearch covers only public registry items
  3. CSearch needs the module's exact version
  4. DSearch matches titles only
Show the answer and why
  • APrivate modules are hidden from search

    Incorrect

    Every user in the organization can view the private registry.

  • BSearch covers only public registry items

    Incorrect

    Private items can be searched and filtered.

  • CSearch needs the module's exact version

    Incorrect

    Versions are chosen on the details page.

  • DSearch matches titles only

    Correct

    The search field filters for titles that contain a keyword and does not include README content.

Choose module names that contain the terms people will search for.

Practice domain 6 →Practice all domains →