[Avg. reading time: 3 minutes]
IaC Concept: Idempotency
What is Idempotency?
Idempotency means:
Running the same code multiple times produces the same result.
Simple Example
If your code says:
- Create 1 Virtual Machine
Then:
- Run once : VM is created
- Run again : No duplicate VM
- Run again : Still only 1 VM
Why This Matters
Without idempotency:
- You might create duplicate resources
- Systems become inconsistent
- Hard to manage infrastructure
With Idempotency (IaC)
- Safe to run deployments multiple times
- Ensures desired state is maintained
- Prevents duplication
Real-World Analogy
Think of a light switch:
- Turn ON : light is on
- Turn ON again : still on (no change)
Same idea with infrastructure.
In Azure (ARM Templates)
- You define the desired state
- Azure checks current state
- Only applies necessary changes
IaC is not about “running commands”
It is about:
Declaring the final state and letting the system reach it