0
0
Terraformcloud~20 mins

Declarative vs imperative IaC in Terraform - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
IaC Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Declarative Infrastructure as Code

Which statement best describes the declarative approach in Infrastructure as Code (IaC)?

AYou write code that specifies the desired end state of the infrastructure, and the tool figures out how to achieve it.
BYou write step-by-step commands to create and configure each resource manually.
CYou must manually run each command in sequence to build the infrastructure.
DYou write scripts that only describe the current state without any changes.
Attempts:
2 left
💡 Hint

Think about whether you describe the final setup or the steps to get there.

Architecture
intermediate
2:00remaining
Identifying Imperative IaC Characteristics

Which of the following Terraform configurations shows an imperative style rather than declarative?

Note: Terraform is declarative by design, but consider which option mimics imperative behavior.

AUsing variables and outputs to parameterize and share data between modules.
BDefining a resource block with desired attributes and letting Terraform manage creation.
CUsing <code>provisioner "local-exec" { command = "echo Setup" }</code> to run shell commands during resource creation.
DWriting a Terraform module that describes a reusable infrastructure component.
Attempts:
2 left
💡 Hint

Imperative style involves explicit commands or scripts executed step-by-step.

service_behavior
advanced
2:00remaining
Terraform Plan Behavior in Declarative IaC

What does the terraform plan command do in the context of declarative Infrastructure as Code?

AIt deletes all existing resources before creating new ones.
BIt immediately applies changes to the cloud infrastructure without confirmation.
CIt only validates the syntax of the Terraform files without checking infrastructure state.
DIt shows the exact steps Terraform will take to change the infrastructure to match the declared configuration.
Attempts:
2 left
💡 Hint

Think about how Terraform previews changes before applying them.

security
advanced
2:00remaining
Security Implications of Imperative vs Declarative IaC

Which security risk is more likely when using imperative Infrastructure as Code compared to declarative?

AAutomatically enforcing consistent security policies across all resources.
BInadvertently skipping critical configuration steps leading to insecure resources.
CHaving a clear, auditable record of desired infrastructure state.
DUsing version control to track infrastructure changes.
Attempts:
2 left
💡 Hint

Consider how manual steps can cause mistakes.

Best Practice
expert
3:00remaining
Choosing Between Declarative and Imperative IaC

You manage a large cloud infrastructure that changes frequently. Which approach is best to ensure reliable, repeatable deployments and why?

ADeclarative IaC, because it defines the desired state and lets the tool handle changes, reducing human error.
BImperative IaC, because writing scripts for each step gives full control over deployment order.
CImperative IaC, because it requires less upfront planning and is faster to write for small changes.
DDeclarative IaC, because it requires manual execution of each command to verify correctness.
Attempts:
2 left
💡 Hint

Think about scalability, repeatability, and error reduction.