Understanding Declarative vs. Imperative

Understanding Declarative IaC in SAP BTP

Imagine you're instructing someone on how to assemble a piece of furniture. There are two ways to do it:

  1. Declarative Approach: In this approach, you provide a clear, high-level description of what the final furniture should look like, but you don't get into the nitty-gritty details of how to put it together. It's like saying, "I want a bookshelf with five shelves," without specifying each step of construction.

    In terms of IaC, this is similar to using a declarative language or configuration files to define your desired infrastructure state. You describe what you want your IT setup to be like (e.g., "I want three servers with these specifications"), and the IaC tool figures out how to make it happen.

  2. Imperative Approach: On the other hand, the imperative approach involves providing detailed, step-by-step instructions for assembling the furniture. You might say, "Attach this piece to that one, then tighten these screws," providing precise guidance for each action.

    In the context of IaC, this would be like using imperative scripts or commands that explicitly specify each action to create and configure resources.

Now, let's compare:

  • Declarative IaC: It's like having a high-level blueprint for your furniture, allowing you to describe your desired end result without getting bogged down in the specifics of construction. Declarative IaC focuses on the "what" rather than the "how."

    For SAP BTP, this is like using IaC configuration files to declare your infrastructure's desired state. You state your intentions, and the IaC tool takes care of the execution.

  • Imperative (API/CLI): This is akin to providing detailed assembly instructions, specifying every action to be taken. It offers more granular control but may require a deeper understanding of the inner workings.

In the context of IaC, you can choose between the declarative approach (describing what you want) or the imperative approach (specifying each step) based on your needs and preferences. Declarative IaC simplifies infrastructure management by focusing on the end goal and leaving the implementation details to the IaC tool. It's like ordering custom-made furniture by describing your preferences, and the skilled craftsman takes care of the rest! 🏠🧰

Last updated