Why is Terraform so good?

In addition to the positives of using infrastructure-as-code, Terraform also provides a host of other benefits.

Declarative

Terraform uses a declarative style of code, which is used to define the required end state of your system’s infrastructure. Declarative code means you describe what you want to be achieved rather than how. The how is instead left to the programming language’s implementation. The opposite of this is a procedural style, which is used to control the flow and state of an application as implemented by languages such as C# or JavaScript.

The positives of a declarative style include increased immutably and reduced side effects. It generally also makes code easier to read and more understandable. Terraform uses HCL (Hashicorp Configuration Language), which has been specifically designed to be written and modified by humans. This means it is easy to see what has been deployed and you don’t need to be computer literate to understand the current state of the system.

Immutable

Iteratively updating infrastructure in place is known as mutable infrastructure, as over time different changes are applied to a system to achieve its current state. This can lead to configuration drift between different resources or environments and creates snowflake servers, which can end up being difficult to reproduce.

Due to its declarative style, Terraform’s definition files can be used to produce an immutable infrastructure. This allows systems to be consistently recreated from scratch, which helps to avoid configuration drift, makes it easy to reproduce systems across different environments and prevents changes that go unrecorded.

Transparent

Thanks to an intuitive CLI and simple definition files, Terraform is very transparent. Again, due to its declarative nature, it is very easy to see the current state of a system and, when making changes, the desired state is also just as straightforward.

Before updating your infrastructure, the Terraform plan and apply commands provide a clear view of what will change in your system before you agree to update. When running the commands, it is easy to back out if you notice anything unexpected.

Simple

The clear HCL definition files combined with the small number of CLI commands make Terraform simple to understand. This means there is a relatively short learning curve, which makes it easy to get started.

Fast

Deploying changes is very fast, as Terraform has functionality that can be used to maintain the current state of the system. When changes are applied, it knows exactly what needs to be created, modified or deleted and it can skip everything else.

Platform agnostic

Terraform supports a wide range of providers, from AWS and Azure all the way through to Githib and Grafana. Essentially, anything with an API can be built into a Terraform provider.

Client-Only Architecture

Terraform is distributed as a single executable, which only needs to be installed on the machine executing the commands. There is no need to install, maintain and configure extra software across your estate compared with a client-server architecture.

Open Source

Terraform and all of its providers are open source. The repositories on Github are very active and open to new features and pull requests from the Hashicorp community.