Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

Terraform vs. CloudFormation

Adnan Abbas

Terraform is an open-source tool for building, modifying, and versioning infrastructure. It uses a declarative configuration language known as HashiCorp Configuration Language (HCL).

However, there is another infrastructure-as-code tool available known as CloudFormation developed by Amazon.

We will be comparing these platforms to see which tool provides an edge in the various features they offer.


Terraform is open source and is generally faster than CloudFormation. So, the integration of new features in the platform is faster in Terraform. In addition, each Terraform provider (a plugin to manage a certain vendor or component) is a separate binary that gets deployed at its own speed.


Terraform beats CloudFormation in modularity as it is cloud-agnostic and can incorporate any resource. It includes native support for third-party modules. As a result, it provides an edge in usability. Whereas, CloudFormation does not have first-class support for modules. It has different approaches to modularizing the infrastructure using nested stacks and templates.

Code readability

CloudFormation uses JSON or YAML for configuration. Both syntaxes are verbose, difficult to perceive, and pose some issues such as indentation.

On the other hand, Terraform uses HCL, which has a cleaner syntax. It allows commenting (both inline and block) in code and is not troublesome with indentations, spacing, or newlines.

State management

In CloudFormation, the state is managed with so-called stacks. Whereas, Terraform stores the state on the local disk by default. In addition, Terraform supports backends such as S3 and DynamoDB to synchronize state and state locking. With CloudFormation, there is a plus that it provides state management out-of-the-box compared to Terraform, where you would have to configure remote state manually.

Wait conditions

It is useful to add wait conditions in your infrastructure automation tools. For instance, a service might have to wait before another service is hosted on a virtual machine. Using wait conditions enables you to wait for signals sent via HTTPS in scenarios where dependent resources are created or updated when using CloudFormation.

In this regard, CloudFormation is ahead as Terraform does not support wait conditions.



Adnan Abbas
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring