Chapter 4 of 8 · HashiCorp Terraform Associate 004

Terraform Configuration

Resources, data sources, variables, types, expressions, dependencies, conditions, secrets.

  • 4topics
  • 19 minfast track

Topics in this chapter

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

  1. 1Resources, Data Sources and ReferencesTerraform Associate 004: resource versus data blocks, reference syntax for attributes, count and for_each instances, splat…5 min
  2. 2Variables, Outputs and Complex TypesTerraform Associate 004: input variables, tfvars files and precedence, outputs, locals, and the list, set, map, object and tuple…5 min
  3. 3Expressions, Functions and DependenciesTerraform Associate 004: conditionals, for expressions, dynamic blocks, built-in functions, implicit and explicit dependencies…4 min
  4. 4Custom Conditions and Sensitive DataTerraform Associate 004: validation, preconditions, postconditions and check blocks, plus sensitive values, ephemeral values…5 min

About this chapter

What this chapter covers

Terraform configuration is the HCL you write to describe infrastructure. This chapter covers the building blocks of that language and how they fit together in a working configuration.

It has four parts: resource and data blocks and the references between them; input variables, outputs and complex types; expressions, functions and dependencies; and custom conditions together with the safe handling of sensitive data, including secrets from Vault.

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

Blocks and referencesresource and dataInputs and outputsvariables, typesExpressionsfunctions, dependenciesConditions and secretsvalidate and protect

Resource and data blocks are the objects; references connect them. Variables feed values in and outputs pass results out, expressions shape those values, and custom conditions and sensitive data rules keep the configuration correct and safe.

  • Block questions ask whether a resource or a data block fits, and how to write a reference.
  • Variable questions ask about precedence, tfvars files, outputs and which type fits a value.
  • Expression questions show a snippet and ask what a conditional, for expression or function returns.
  • Dependency questions ask when depends_on is needed and what a lifecycle setting does.
  • Condition and secret questions ask which check stops a run and what is stored in state.
Exam tip

When a snippet appears, check the prefix first. var., local., data. and module. each point to a different kind of block, and many wrong options drop or swap the prefix.

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.