SaveMyCert
Log in
5 of 5 free questions left today·for 10 a day
Terraform Pro 002 · Domain 6

Advanced module usage and registry practices practice questions

Advanced module usage and registry practices is worth 10% of the Terraform Pro 002 exam — the 6th-heaviest of the 7 domains. When to extract a module, the module contract, building with the Terraform registry, and validating modules with terraform test. Weight approximates the sub-objective share. 6 fully worked examples are further down this page, answers included.

Exam weight
10%
the 6th-heaviest of the 7 domains
Questions
80
across 2 topics
Free, no account
5/day
a free account allows 10 a day
Explanations
Every option
right and wrong

Build a practice session

5 free questions left today.

Domains

How many?

Mode

Ready when you are

10 fresh questions drawn across 1 of 7 domains, in Learn mode.

Review what you missed

Every question you answer incorrectly, and every question you flag while practising, is saved here automatically. Finish a session and you can come back to re-drill just those.

6 sample Advanced module usage and registry practices questions, fully explained

Questions from the Terraform Pro 002 bank mapped to domain 6, with the answer key and the reasoning behind every option. None of them repeat the examples on the main Terraform Pro 002 practice page.

Question 1Advanced module usage and registry practices

A platform team must guarantee that every S3 bucket created by application teams has default encryption, versioning and a public access block. Application teams should decide only the bucket name and the log retention period. What should the platform team provide?

Choose one.

  • a
    A module that exposes each bucket setting as an input with secure default values

    Secure defaults can be overridden by any caller, so nothing guarantees the three controls.

  • b
    A tfvars file with secure values, name and retention that each team copies in

    A copied variables file only supplies values to whatever configuration a team writes; it enforces nothing and drifts per copy.

  • c
    A module that sets the three controls internally and takes name and retention Correct

    The controls are hard-coded inside the module, so callers cannot switch them off; the interface exposes only the two decisions callers own.

  • d
    A locals block of secure settings that each team's bucket resources reference

    Each team still writes its own resources and may ignore or edit the locals, so the controls are not guaranteed.

The concept

A module enforces standards by keeping opinionated settings inside and exposing only the choices that belong to the caller.

Why that’s the answer

Encapsulating organisational standards is a core reason to write a module: the module's interface is its inputs, so anything not exposed as an input cannot be changed by callers. Exposing every argument with secure defaults looks flexible but lets callers override the controls, and shared tfvars or locals rely on every team wiring them correctly.

How to reason it out
  1. List what must be guaranteed and what callers may choose.
  2. Check whether each option lets a caller override a guaranteed control.
  3. Prefer the option whose inputs are only the caller-owned decisions.

Exam tip: What a module does not expose as an input, its callers cannot change.

Terraform Professional (002): Refactoring into Modules and the Module Contract — the lesson that teaches this.

Question 2Advanced module usage and registry practices

A root configuration has three near-identical copies of a queue, its dead-letter queue and an alarm, differing only in name and thresholds. Two other teams' root configurations will need the same set next quarter, and each of those teams must be able to adopt updates on its own schedule. How should the set be refactored?

Choose one.

  • a
    Move the set into ./modules/queue-set in this repository and call it with for_each

    A local path works inside this repository, but other teams would have to copy it, and there is no release to pin, so they cannot upgrade on their own schedule.

  • b
    Publish the set as a tagged module in its own repository and have callers pin a release Correct

    A versioned module removes the copies here and lets each consuming team pin a release and move to a newer one when it chooses.

  • c
    Keep the resources in the root and drive the three resource types from one for_each map

    for_each removes the three copies in this root, but nothing is reusable by the other teams' configurations.

  • d
    Publish the set in a shared repository that callers reference at its main branch

    Tracking a branch gives every caller every change on its next init, which breaks the requirement to upgrade independently.

The concept

Choosing between a local module, a versioned shared module and plain for_each depends on who reuses the code and how they adopt changes.

Why that’s the answer

All four options reduce duplication in this root. The deciding constraints are reuse by other root configurations and independent upgrades. Only a module published with release tags (or in a registry) that callers pin satisfies both: each team chooses when to change its pinned version. A local ./modules path is not consumable as a release by other repositories, for_each is not reusable at all, and a branch reference pushes every change to every caller at once.

How to reason it out
  1. Confirm that every option removes the copies in this root.
  2. Apply the first constraint: other root configurations must reuse it.
  3. Apply the second: each consumer adopts updates on its own schedule.
  4. Only a released, pinnable module meets both.

Exam tip: Reuse across configurations plus independent upgrades means a versioned module, not a local path or a branch.

Terraform Professional (002): Refactoring into Modules and the Module Contract — the lesson that teaches this.

Question 3Advanced module usage and registry practices

A team proposes a module named security-group that contains one aws_security_group resource and passes every argument of that resource through as an input variable. What does HashiCorp's module development guidance recommend?

Choose one.

  • a
    Add validation blocks to the security group module for each wrapped argument

    Validation does not change the fact that the module is a thin wrapper that adds no new concept.

  • b
    Move the module under modules/ and add a README for external callers

    Where the module lives does not address the problem; it still wraps one resource without abstraction.

  • c
    Use the aws_security_group resource directly in the calling configuration Correct

    A module that only mirrors one resource's arguments adds no abstraction, so the guidance is to use the resource type directly.

  • d
    Publish the security group module as a versioned release that callers pin

    Versioning a thin wrapper adds release overhead to every change while still adding no abstraction.

The concept

HashiCorp recommends against modules that are thin wrappers around a single resource type.

Why that’s the answer

A good module raises the level of abstraction by describing a new concept built from several resources. A module that exposes exactly one resource's arguments makes callers learn a second interface for the same thing. The guidance is to use the resource directly; one hint is that you cannot name the module anything other than its main resource type.

How to reason it out
  1. Count what the module adds: one resource, arguments passed straight through.
  2. Recall HashiCorp's guidance on thin wrappers.
  3. Reject options that decorate, relocate or version the wrapper without adding a concept.

Exam tip: If a module mirrors one resource, use the resource.

Terraform Professional (002): Refactoring into Modules and the Module Contract — the lesson that teaches this.

Question 4Advanced module usage and registry practices

A platform team reviews four module proposals for its internal catalogue. Which proposal best fits HashiCorp's module development and composition guidance?

Choose one.

  • a
    A module bundling the shared VPC with each team's services behind create_* flags

    It combines many resource types, but a flag-driven catch-all module couples unrelated owners; the composition guidance prefers small modules composed in the root.

  • b
    A module wrapping one aws_s3_bucket resource that exposes each argument as an input

    This is a thin wrapper around a single resource type, which the guidance advises against.

  • c
    A module wrapping one aws_lb resource that renames its arguments to the team's style

    Renaming arguments still leaves a single-resource wrapper that callers must learn in addition to the resource.

  • d
    A module creating a container service with its security groups, IAM roles and DNS Correct

    It combines several resource types into one architectural concept, which is what a module is for.

The concept

A module should introduce a new architectural concept composed of several resources.

Why that’s the answer

HashiCorp's guidance describes modules as containers for resources that are used together, ideally forming a higher-level concept such as a service with its networking, identity and DNS. Single-resource wrappers, whether they pass arguments through or rename them, add interface without abstraction. Combining several resource types is not enough on its own: a catch-all module that bundles shared networking with every team's services behind create_* flags mixes owners and change rates, and the composition guidance favours small modules composed in the root instead.

How to reason it out
  1. For each proposal, ask what new concept a caller gets.
  2. Discard single-resource wrappers, whether they pass arguments through or rename them.
  3. Discard catch-all modules steered by create_* flags.
  4. Choose the proposal that composes one service's resources into one unit.

Exam tip: A module earns its place by adding a concept, not by renaming a resource.

Terraform Professional (002): Refactoring into Modules and the Module Contract — the lesson that teaches this.

Question 5Advanced module usage and registry practices

A team is splitting a customer-facing service into modules. Its database cluster is long-lived and changes a few times a year; its container service definitions change several times a day. Following HashiCorp's module creation guidance, how should these be scoped?

Choose one.

  • a
    Combine both in one module and set prevent_destroy on the database cluster

    prevent_destroy blocks one kind of accident but keeps the stable database inside a module that changes daily.

  • b
    Split networking out, keeping the cluster and the services in one module

    This splits the module, but the yearly-changing database still shares a module with daily-changing services.

  • c
    Split by privilege: IAM roles in one module, cluster and services in another

    Privilege boundaries are a real scoping test, but here the deciding difference is change rate, and this split still couples the database with the services.

  • d
    Place the database cluster and the container services in a module each Correct

    Separating long-lived from short-lived infrastructure limits churn and risk around the stateful database.

The concept

Scope modules by volatility: keep long-lived, stateful infrastructure apart from frequently changed infrastructure.

Why that’s the answer

HashiCorp's module creation pattern names three scoping tests: encapsulation (group what is always deployed together), privileges (respect team privilege boundaries) and volatility (separate long-lived from short-lived infrastructure). A database that changes yearly and services that change daily fail the volatility test, so they belong in separate modules. prevent_destroy is a workaround that keeps the coupling, and splits along other lines (networking, IAM) leave the database and the services together.

How to reason it out
  1. Note the different change rates in the stem.
  2. Recall the volatility rule from HashiCorp's module creation guidance.
  3. Check each split: does it separate the database from the services?
  4. Reject options that keep both together, even if they split something else.

Exam tip: Separate what changes yearly from what changes daily.

Terraform Professional (002): Refactoring into Modules and the Module Contract — the lesson that teaches this.

Question 6Advanced module usage and registry practices

A platform team is drafting modules for a payments workload: VPC networking owned by the network team, a database cluster, KMS keys that only the security team may administer, and Lambda functions the application team deploys daily. Which TWO scoping decisions follow HashiCorp's module creation guidance? (Select TWO.)

Choose TWO.

  • a
    Keep each resource type, such as the database cluster, in a module of its own

    One module per resource type produces thin wrappers that add no abstraction.

  • b
    Keep the payments resources in one module because they serve one workload

    Serving one workload is not the test; the resources differ in ownership and rate of change.

  • c
    Keep the KMS keys in a module of their own, apart from the application team's code Correct

    Modules should respect privilege boundaries; keys administered only by security should not live in code the application team changes.

  • d
    Keep the KMS keys with the application functions, because the functions use them

    A dependency is passed through inputs and outputs; it does not override the privilege boundary.

  • e
    Keep the daily-deployed functions apart from the long-lived database cluster Correct

    Separating short-lived from long-lived infrastructure reduces churn and risk for the stateful cluster.

The concept

Encapsulation, privileges and volatility decide module scope; a dependency between resources does not.

Why that’s the answer

The guidance groups resources that are always deployed together, restricts modules to privilege boundaries and separates long-lived from short-lived infrastructure. Security-administered KMS keys cross a privilege boundary with application code, and daily functions differ in volatility from the database. Dependencies such as functions using a key are expressed by passing the key ARN as an input, so they do not force co-location. One module per resource type swings to the opposite anti-pattern.

How to reason it out
  1. Identify ownership: network, security and application teams.
  2. Identify change rates: daily functions versus a long-lived database.
  3. Apply the privilege and volatility rules to choose the splits.
  4. Remember that dependencies flow through inputs, not shared modules.

Exam tip: Split by who may change it and how often it changes; wire dependencies through inputs.

Terraform Professional (002): Refactoring into Modules and the Module Contract — the lesson that teaches this.

What Terraform Pro 002 domain 6 tests, topic by topic

The official exam guide breaks Advanced module usage and registry practices into 2 topics. The question bank follows the same split, so a weak topic shows up as a cluster of misses you can go back and read.

Published Terraform Pro 002 practice questions per topic in Advanced module usage and registry practices
TopicWhat it coversQuestions
Refactoring into modules and the module contractOfficial Terraform Infrastructure Engineer Professional (002) objectives, 6a Understand when to refactor a Terraform configuration into a module; 6b Understand the contract of a Terraform module.40
The Terraform registry and module testsOfficial Terraform Infrastructure Engineer Professional (002) objectives, 6c Use the Terraform registry to build or update a configuration; 6d Validate modules with Terraform unit tests.40
Total80

Revise Advanced module usage and registry practices before you drill it

Other Terraform Pro 002 domains

Advanced module usage and registry practices: your questions

Advanced module usage and registry practices is domain 6 of the Terraform Pro 002 exam guide and carries 10% of the scored content — the 6th-heaviest of the 7 domains. HashiCorp has not yet published the exam's question count, so there is no per-domain number of questions to give.

Source

The domain weight and topic list on this page come from the official Terraform Pro 002 exam guide.