Chapter 5 of 8 · HashiCorp Terraform Associate 004

Terraform Modules

Module sources, how init installs them, variable scope, calling modules and version constraints.

  • 2topics
  • 10 minfast track
  • 1diagrams and exhibits

Topics in this chapter

Take them in order, or jump to the one you need.

  1. 1Module Sources and Variable ScopeTerraform Associate 004: module sources from local paths to registry, Git, HTTP and S3, how init installs them, and how inputs…Diagram5 min
  2. 2Using Modules and Managing VersionsTerraform Associate 004: calling modules with inputs, count and for_each, standard module structure, version constraints and…5 min

About this chapter

What this chapter covers

Modules package Terraform configuration so you can reuse it. This chapter covers where module code comes from, how values move between a module and its caller, and how you call and version modules safely.

It has two parts: module sources and variable scope, then calling modules in configuration and managing their versions with constraints and terraform init.

Questions are single-answer, multiple-answer ("Pick the 2 correct responses below") and true or false statements, mostly direct recall of commands and behavior plus short HCL snippets that open "Consider the following configuration snippet:". There are no exhibits.

How the topics fit together

Sourcewhere the code livesterraform initinstalls the moduleModule blockinputs passed inOutputsvalues passed back

The source argument says where the module lives and terraform init installs it. The caller then passes values in through input variables and reads results back through outputs, while the version constraint controls which release is used.

  • Source questions ask which source string is valid for a local path, registry, Git or bucket.
  • Scope questions ask how a child gets a value and how the parent reads one back.
  • Usage questions show a module block and ask what each argument does.
  • Version questions ask what a constraint allows and which sources accept version.
Exam tip

Many module questions turn on one detail. Look for a missing ./ on a local path, a version argument on a Git source, or a parent trying to read a child's resource directly.

How to use these pages

Each topic page has the same shape, so you can skim for what you need.

  • What it is: the idea in plain words.
  • How it works: the mechanism, with tables and examples.
  • What to remember for the exam: the facts to memorize and how questions are phrased.
  • Common mistakes: the classic traps.
  • Check yourself: three questions to test your understanding.

Ready for more practice?

The full HashiCorp Terraform Associate 004 question bank has 600 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by HashiCorp. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.