004 · Domain 1: Infrastructure as Code (IaC) with Terraform · 12% of the exam
Task 1.2: Describe the advantages of IaC patterns
Why teams adopt it: changes reviewed like code, a plan before every change, repeatable environments, reusable modules, an audit trail in version control, fewer manual mistakes, and drift you can see.
Study it
Why IaC: version history, review, plans, repeatable and disposable environments
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.
Question 1 · choose 2
After an outage, an auditor asks who changed a load balancer's listener port, when, and why. The team manages the load balancer with Terraform and keeps its configuration in Git, with changes merged through reviewed pull requests. Which two sources answer the auditor? (Choose TWO.)
AThe state file keeps a full history of every attribute value and the user who set it
BThe configuration's commit history shows the change, its author, date and reason
CThe provider writes the Terraform user name into a tag on every resource it changes
DTerraform keeps a log of every plan in the .terraform directory for later audits
EThe pull request that introduced the change, with its review and approval
Show the answer and why
AThe state file keeps a full history of every attribute value and the user who set it
Incorrect
State records the current mapping to real objects; it is not an authorship log of configuration changes.
BThe configuration's commit history shows the change, its author, date and reason
Correct
Because the configuration is a file you can version, version control keeps who changed it, when, and the reason in the commit and its review.
CThe provider writes the Terraform user name into a tag on every resource it changes
Incorrect
Providers do not add authorship tags by themselves; any tags come from the configuration.
DTerraform keeps a log of every plan in the .terraform directory for later audits
Incorrect
The .terraform directory holds the working directory's providers, modules and backend settings, not an audit trail.
EThe pull request that introduced the change, with its review and approval
Correct
Teams review configuration changes alongside pull requests, so the pull request records who reviewed and approved the change.
Configuration files in version control give infrastructure the same history as application code: every change has an author, a time, a reason and, usually, a review.
A team that changes firewall rules by hand has twice deleted a rule that production depended on. They move the rules to Terraform. Which Terraform behavior most directly prevents this kind of surprise?
ATerraform refuses to delete any resource that another resource depends on
BTerraform shows a plan of every change and waits for approval before making it
CTerraform keeps a backup copy of every deleted firewall rule so it can be restored later
DTerraform locks each firewall rule so nobody can change it outside Terraform
Show the answer and why
ATerraform refuses to delete any resource that another resource depends on
Incorrect
Terraform orders deletions by dependency but will still delete what the plan proposes; dependencies do not make a resource undeletable.
BTerraform shows a plan of every change and waits for approval before making it
Correct
Terraform generates a plan and prompts for approval before modifying infrastructure, so an unintended deletion is visible before it happens.
CTerraform keeps a backup copy of every deleted firewall rule so it can be restored later
Incorrect
Terraform does not back up remote objects it destroys. Only the state file has a local backup.
DTerraform locks each firewall rule so nobody can change it outside Terraform
Incorrect
Terraform cannot stop changes made outside it; state locking only stops two Terraform runs from writing the same state.
The plan is the safety net of the workflow: every proposed change, including each deletion, is shown for review before apply makes it.
A company opens a new region and needs the same networking, load balancers and instance groups it already runs in two other regions, all built from Terraform. Compared with rebuilding by hand, what is the main gain?
ATerraform copies the running resources from the other regions without needing configuration
BThe existing configuration, applied with new inputs, builds the region the same way
CThe new region skips planning because the configuration was already applied elsewhere
DThe new region needs no provider configuration because the providers are already installed
Show the answer and why
ATerraform copies the running resources from the other regions without needing configuration
Incorrect
Terraform creates what the configuration describes; it does not clone live resources.
BThe existing configuration, applied with new inputs, builds the region the same way
Correct
IaC lets you build and change infrastructure in a consistent, repeatable way by reusing configurations.
CThe new region skips planning because the configuration was already applied elsewhere
Incorrect
Each environment gets its own plan against its own state.
DThe new region needs no provider configuration because the providers are already installed
Incorrect
Installed providers still need configuration, for example the new region.
Repeatability is speed: once the infrastructure is code, building it again is an apply, not a project.
A small team needs a production-grade virtual network with public and private subnets, routing and NAT, and has little time. Which Terraform advantage helps most?
AUsing a published module from the Terraform Registry
BUsing terraform console to generate the network resources interactively
CCopying another company's state file that already contains a network
DAsking the provider to choose sensible subnets during terraform init
Show the answer and why
AUsing a published module from the Terraform Registry
Correct
Publicly available modules on the Terraform Registry package collections of resources, saving time and encouraging best practices.
BUsing terraform console to generate the network resources interactively
Incorrect
console evaluates expressions; it does not write configuration.
CCopying another company's state file that already contains a network
Incorrect
Someone else's state refers to their objects and would not create a network for this team.
DAsking the provider to choose sensible subnets during terraform init
Incorrect
init installs providers and modules; it does not design networks.
Modules are reusable infrastructure. The public registry means many common patterns are already written and versioned.
Every hand-built server in a fleet has slightly different settings because each was configured by a different person. What does defining the fleet in Terraform change?
ATerraform inspects existing hand-built servers and standardizes them without configuration
BTerraform prevents anyone from logging in to a server it created
CTerraform guarantees that the application on each server has no configuration bugs
DEach server comes from the same definition, so settings no longer vary by builder
Show the answer and why
ATerraform inspects existing hand-built servers and standardizes them without configuration
Incorrect
Terraform changes what its configuration describes; it does not standardize unmanaged servers on its own.
BTerraform prevents anyone from logging in to a server it created
Incorrect
Access to servers is governed by the platform's access controls, not by Terraform.
CTerraform guarantees that the application on each server has no configuration bugs
Incorrect
Terraform provisions infrastructure; it cannot vouch for application settings it does not manage.
DEach server comes from the same definition, so settings no longer vary by builder
Correct
IaC builds infrastructure in a safe, consistent and repeatable way from configuration you can reuse, which removes person-to-person variation.
Consistency is a direct product of IaC: one definition, many identical copies, and no step left to memory.
A module team wants to catch breaking changes to its modules automatically before releasing a new version, the way application teams run unit tests. Which capability does Terraform provide for this?
AThe terraform validate command, which creates temporary resources to test the module
Bterraform test, which runs test files with run blocks and assertions
CThe terraform graph command, which fails when a module has a breaking change
DThe terraform fmt -check command, which compares the module with its previous version
Show the answer and why
AThe terraform validate command, which creates temporary resources to test the module
Incorrect
validate never creates resources or contacts remote services.
Bterraform test, which runs test files with run blocks and assertions
Correct
terraform test runs .tftest.hcl files with run blocks and assertions, so infrastructure code can be tested like application code.
CThe terraform graph command, which fails when a module has a breaking change
Incorrect
graph prints the dependency graph; it does not check behavior.
DThe terraform fmt -check command, which compares the module with its previous version
Incorrect
fmt -check only reports formatting differences.
Treating infrastructure as code includes testing it. terraform test brings automated assertions to modules.