Choose module keys that survive changing inventory
A hands-on TERRAFORM-004 lab. You produce the real artefact and 9 automated checks verify it behaves the way the exam expects.
Try this labAll TERRAFORM-004 practice
- Certification
- TERRAFORM-004
- Format
- Structured configuration
- Difficulty
- medium
- Estimated time
- 25 min
- Automated checks
- 9
The brief
Edit workers.tf.json. Keep the workers module source ./modules/worker and pass each complete inventory record into its service input. All inventory records must be admitted, including enabled = false: that flag is a setting in the supplied child, not a deletion instruction. Choose instance keys from an attribute whose value remains stable when a name changes, another record is inserted or the list is reordered. Preserve each existing object's physical ID when migrating the two count-based module instances; include static moved module-instance addresses. Future retirement must destroy only the removed logical object. Run tests to inspect desired addresses, retained IDs and create/update/destroy actions for each supplied snapshot. Updates to mutable name values are allowed; identity replacement or reassignment is not. Supported Terraform JSON expression forms are count = ${length(var.inventory)} with service = ${var.inventory[count.index]}, or for_each = ${{ for unit in var.inventory : unit.FIELD => unit }} with service = ${each.value}; an index local and tostring(index), a boolean record-field filter, and ${zipmap(var.inventory[*].FIELD, var.inventory)} are also supported so their consequences can be inspected. Map keys may use supported primitive record attributes. Only this module call, its repetition and service argument, and static module-instance moved blocks belong in the editable artifact. Arbitrary functions, additional module arguments and resource-level moves are outside this bounded exercise. Repair normal edits without Reset.
What the checks verify
Your work is graded on 9 independent properties, not on matching one reference answer.
- The artifact uses supported module repetition expressions and static module-instance moves.
- The supplied workers child receives each selected complete inventory record.
- Initial unit-a retains its original physical ID after the refactor.
- Initial unit-b retains its original physical ID after the refactor.
- Renaming a display name preserves both surviving logical objects' physical IDs.
- Prepending unit-c admits the new object while preserving both original IDs.
- Reordering inventory preserves each surviving object's original physical ID.
- Retiring unit-a destroys only its original object and preserves unit-b.
- Equal mutable display names still admit both distinct logical inventory records.
Where this sits in the TERRAFORM-004 blueprint
- Domain
- Terraform modules
- Objective
- Module Composition
- Skill
- Stable Module Instance Identity
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.