Prompt
Do I need declarative infrastructure if I already know the steps to create it?
Latest observation
Not strictly — but in practice, often yes.
If you already know the exact steps to create infrastructure, you can absolutely provision it imperatively with scripts or manual commands. The question is less “can you?” and more “what do you gain by being declarative?”
Imperative approach
You say how to do it:
- create VM
- attach network
- open port
- install package
- configure service
This works fine for:
- one-off setups
- very small environments
- experiments and prototypes
- simple automation where drift doesn’t matter much
Declarative approach
You say what the end state should be:
- “I want 3 app servers in this network behind this load balancer”
- “This service should always run with these settings”
The tooling figures out the steps and keeps things aligned over time.
Why declarative is useful even if you know the steps
Knowing the steps doesn’t remove these problems:
- Drift: reality changes over time
- Repeatability: humans and scripts make mistakes
- Idempotence: re-running should be safe
- Scale: the more resources you have, the harder it is to manage imperatively
- Reviewability: desired state is easier to audit in code
- Rollback and reconstruction: easier to recreate from definition than from a sequence of actions
Rule of thumb
- If the infrastructure is small, temporary, or rarely changed, imperative may be enough.
- If it is shared, production, long-lived, or compliance-sensitive, declarative infra is usually worth it.
A simple way to think about it
Imperative infra says:
“Here are the steps.”
Declarative infra says:
“Here’s the result I want. Keep it that way.”
So: you don’t need declarative infrastructure to make infrastructure exist, but you often want it to make infrastructure manageable.
If you want, I can also compare declarative vs imperative infrastructure with a concrete example like Terraform, Ansible, or Kubernetes.