Repair a Terraform module's input contract

A hands-on TERRAFORM-004 lab. You produce the real artefact and 7 automated checks verify it behaves the way the exam expects.

Try this labAll TERRAFORM-004 practice

Certification
TERRAFORM-004
Format
Artifact workspace
Difficulty
easy
Estimated time
20 min
Automated checks
7

The brief

Repair inputs.tf. Declare exactly name and token as required string inputs and replicas as a number defaulting to 2; all three must have nullable = false. Accept names that contain a non-whitespace character, whole-number replicas from 1 through 6 inclusive and tokens at least 12 characters long. Preserve primitive type conversion, including numeric strings for replicas. A null replicas input uses its non-null default; name and token cannot fall back to defaults. Add validation blocks with useful literal error messages. Expose exactly service_name from var.name, instance_count from var.replicas and secret_token from var.token, using direct references. Mark the token input and secret_token output sensitive; keep the other outputs nonsensitive. Run tests for valid inputs, rejected boundary cases and the output interface. Supported expressions are primitive literals, var references, parentheses, lists, comparisons, &&, ||, !, %, and floor, length, trimspace and contains. You may combine conditions or split them into multiple validation blocks. This lab uses ordinary sensitive values, which can persist in state; sensitivity controls display, and does not mean encryption or ephemeral storage.

What the checks verify

Your work is graded on 7 independent properties, not on matching one reference answer.

  • The interface uses the supported well-formed Terraform HCL syntax.
  • The three primitive inputs preserve non-null types and only the replicas default.
  • Valid names, integer boundary counts and sufficiently long tokens remain accepted.
  • Empty and whitespace-only names are rejected.
  • Zero, excessive and fractional replica counts are rejected.
  • Tokens shorter than twelve characters are rejected.
  • Consumer outputs reference their corresponding inputs with deliberate sensitivity.

Where this sits in the TERRAFORM-004 blueprint

Domain
Terraform configuration
Objective
Module Interfaces
Skill
Variables, Outputs and Complex Types

Part of TERRAFORM-004 preparation

Labs are written by ExamNova to teach the decisions the exam tests. They are not reproductions of vendor lab content.