declarative
A style where you describe the end result you want and let the tool work out the steps to get there.
In more detail
A declarative file says what should exist, not how to build it. The tool compares that description with reality and acts only where they differ, so running it twice does nothing the second time. The opposite style, imperative, lists steps to run in order.
Example
In Terraform: A declarative file says what should exist, not how to build it. The tool compares that description with the real world and plans only the changes that are missing, so running it twice does nothing the second time. Terraform configuration is declarative; a shell script is the opposite, imperative, style.Related terms
- imperative — A style where you list the exact steps to run, in order, like a recipe.
- desired state — A description of how a machine should look when the work is finished, rather than a list of 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.
- infrastructure as code — Describing servers, networks and other infrastructure in text files that a tool reads to create and change the real thing.
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