TF-Associate-004 - Infrastructure as Code (IaC) with Terraform - Section 1a

Explain what Infrastructure as Code (IaC) is.

IaC is the practice of defining infrastructure in machine-readable configuration files that are version-controlled and applied by a tool rather than provisioned by hand. Candidates should be able to distinguish declarative configuration, which describes desired end state, from imperative scripting that lists steps, and explain why Terraform reads a configuration and reconciles reality toward it.

declarative configurationdesired stateversion-controlled infrastructureprovisioning tool

Practice question for this objective

Free sampleInfrastructure as Code (IaC) with Terraformeasy

Terraform is often described as using a declarative approach to Infrastructure as Code. What does a declarative configuration specify?

  • AThe exact ordered sequence of API calls the tool must execute to build each resource.
  • BA shell script that engineers run by hand whenever a resource needs changing.
  • CThe desired end state of the infrastructure, leaving the tool to work out the actions needed to reach it. Correct
  • DThe precise loops and conditionals that iterate over the provider until each resource exists.
A declarative configuration states the desired end state and lets the tool decide the steps to achieve it. In a declarative model the practitioner defines the target state and the tool computes the difference between current and desired state, then performs the actions needed, rather than being told each step explicitly.

Why A is wrong: Specifying an ordered sequence of steps is the imperative approach; it is tempting because tools do make API calls, but the practitioner does not script that order in a declarative model.

Why B is wrong: Hand-run shell scripts are an imperative, manual technique; they may change resources but they do not describe a desired end state the tool reconciles to.

Why C is correct: A declarative configuration describes what the infrastructure should look like, and Terraform determines the operations required to reach that state.

Why D is wrong: Explicit loops and conditionals reflect imperative programming logic, which sounds plausible but is not how a declarative configuration expresses intent.

See more TF-Associate-004 practice questions, answers explained.

More in this domain

Back to all Infrastructure as Code (IaC) with Terraform objectives, or the TF-Associate-004 cert hub.

Examworthy is not affiliated with or endorsed by HashiCorp. Original, blueprint-aligned practice material only.