imperative
A style where you list the exact steps to run, in order, like a recipe.
In more detail
Running an imperative script performs its steps again, whatever already exists. Run a script that creates a network twice and you may end up with two networks, because nothing in it checks first. Declarative tools avoid this by comparing a description with reality before acting.
Example
In Terraform: A script is imperative: running it performs its steps again, whatever already exists. Run a script that creates a network twice and you may end up with two networks, because nothing in it checks first. Declarative tools such as Terraform avoid this by comparing a description with reality before acting.Related terms
- declarative — A style where you describe the end result you want and let the tool work out the steps to get there.
- idempotency — The property of an operation that gives the same result whether you run it once or many times, because a repeat run finds nothing left to do.
Taught in
- What Is Infrastructure As Code? — Infrastructure as Code with Terraform
- Infrastructure As Code, And One Workflow For Every Platform — HashiCorp Terraform Associate (004) Exam Prep