Published Sep 3, 2019

SE-Radio Episode 289: James Turnbull on Declarative Programming with Terraform

James Turnbull delves into the advantages of Terraform's declarative programming model for infrastructure management, comparing it to tools like Puppet while highlighting its unique automation, error handling, and debugging features. Discover how Terraform transforms infrastructure as code with its execution plans and parallelism, streamlining management and reducing errors through a visual, graph-based approach.
Episode Highlights
Software Engineering Radio - the podcast for professional software developers logo

Popular Clips

Episode Highlights

  • Programming Models

    explains the fundamental differences between imperative and declarative programming models, highlighting their distinct approaches to problem-solving. In imperative programming, like Bash or Python, you specify each step to achieve a desired outcome, akin to following a checklist. Conversely, declarative programming focuses on the end state, allowing the application to determine the necessary steps. provides examples of declarative languages, such as SQL, where users specify the desired data set without detailing the retrieval process 1. He emphasizes that declarative models simplify complex tasks by abstracting the underlying processes 2.

    In a declarative world, I only care about the end state of the object.

    ---

    notes that declarative languages are popular, though users may not always recognize them as such 1.

       

    Declarative Benefits

    The declarative model offers significant advantages in infrastructure management, as illustrates with examples like firewall rules. He describes how a subtle change in a traditional script could inadvertently affect multiple systems, whereas a declarative approach links resources, allowing for a comprehensive view of potential impacts 3. This model-driven approach enables developers to reason about infrastructure as a set of states, facilitating easier management and error detection. highlights the intuitive nature of this model for software developers, comparing it to familiar concepts like set intersections.

    In a model-driven, declarative world, all of my resources that have some relationship are linked together.

    ---

    adds that this approach was a novel concept for many in the operations world when infrastructure as code first emerged 4.

       

    Terraform Efficiency

    argues that the declarative model is particularly well-suited for tools like Terraform, as it enhances productivity by eliminating the need to remember intricate details of infrastructure setup. He humorously notes that system administrators prefer not to memorize complex commands across different systems, and declarative programming allows them to focus on the desired end state instead 5. This approach not only saves time but also reduces the risk of errors inherent in step-by-step instructions. emphasizes that declarative programming allows for a more straightforward reasoning process, as it focuses on achieving a specific outcome rather than navigating a series of steps.

    I can reason about a declarative world in a way that I can't in an imperative world.

    ---

    concurs, noting that this model aligns well with the goal of achieving a defined end state efficiently 3.

Related Episodes