Exercise 1: Declarative vs. Imperative Provisioning, With Examples — Possible Solution ==================================================================== DECLARATIVE: you describe the DESIRED END STATE, and the tool figures out what changes are needed to get there. Example: a Terraform config file states "I want 3 web server instances and 1 load balancer." If only 1 web server currently exists, the tool computes on its own that it needs to create 2 more, without being told the individual steps -- and if 5 instances already exist instead of 3, running the same config again would compute that 2 need to be REMOVED to match the desired state. The config always describes the END GOAL, not the path to it. IMPERATIVE: you write a specific SEQUENCE OF STEPS to be executed, in order. Example: a shell script that runs "create server 1," then "create server 2," then "create server 3," one command after another. If this script is run a second time without modification, it doesn't know that 3 servers already exist from the first run -- it would simply try to create 3 MORE servers, resulting in 6 total, because it has no concept of a "current state" to compare against; it just executes its fixed sequence of steps every time it's run. WHY THIS WORKS AS AN ANSWER ------------------------------ The examples specifically illustrate the chapter's own distinguishing property -- a declarative tool reconciles CURRENT state against DESIRED state and computes the difference, while an imperative script just re-executes its fixed steps with no awareness of what already exists -- which is exactly why the chapter notes imperative scripting "doesn't inherently know how to safely reconcile drift" the way a declarative plan/apply cycle does.