AWS CloudFormation vs. Terraform

The term "infrastructure as code" (IaC) has been popular recently, and for good reason. IaC, or software-defined infrastructure, is an IT setup where developers or operations teams continuously manage and provision the technological stack for an application via software, rather than manually configuring separate hardware devices and operating systems. As an essential part of DevOps, it attempts to boost productivity, quality, and timeliness in organizations. AWS CloudFormation or the open-source Terraform tool is frequently the first two options that come to mind when looking for tools to implement infrastructure as code on AWS. In order to help you decide which is best for your situation, we'll go over the differences between them.

Cloud Formation

As a service provided by AWS, CloudFormation allows you to model and provision AWS as well as third-party application resources securely and repeatedly. AWS infrastructure modeling and development can now have a single point of reference. Managing dependencies among AWS resources is simplified using CloudFormation. Even more importantly, CloudFormation allows you to make changes in a defined and repeatable manner, making it easier to iterate your infrastructure. Dedicated to AWS, CloudFormation is an AWS-native tool. 

AWS services may be deployed in a segregated fashion using CloudFormation, which simplifies the process of configuring these services and connecting them to one other. CloudWatch allows you to manage your AWS infrastructure in a controlled and predictable manner, allowing you to keep track of your infrastructure’s evolution. With this, testing may be iterated upon and a rollback is possible (when configured properly).


A free and open-source software program called Terraform helps users with the work of establishing and deploying data center infrastructure. Cloud-independent, Terraform codifies APIs into expressive system settings that can be shared, modified, reviewed, and versioned amongst a team of collaborators.

State Management

Both Terraform and CloudFormation require that you keep a record of all resources that are being managed.

Drift detection may be performed on the full supplied infrastructure using CloudFormation, and comprehensive replies are returned when anything has changed. A parameter can be modified without deleting and rebuilding a CloudFormation stack resource for some resources, whereas others are deemed immutable and must be rebuilt. CloudFormation will also check for dependencies before deleting a resource, and it will abort the operation if any are found . A remote location, such as the provisioning computer, is where Terraform keeps track of infrastructure status (for team use). It’s a special JSON format that tells Terraform where to find the resources it’s responsible for managing and how to set up those resources.

A managed AWS service, CloudFormation takes care of all this for you. CloudFormation will constantly monitor the state and configuration of the infrastructure it has supplied in order to ensure that it is doing so. A remote state option is available for Terraform, which saves the state data on a remote data store and may be used by all members of a team if desired. Amazon S3 is supported by Remote State, but you must set it up yourself.



Flexibility is essential in the ever-changing world of infrastructure requirements. When it comes to meeting this demand, both CloudFormation and Terraform offer unique approaches.

Multiple resources can be contained in a single container in Terraform’s modules. Development teams benefit from the increased iteration speed that modules provide by abstracting their infrastructure into reusable and shareable software code. The “nested stacks” system is employed by CloudFormation. Using CloudFormation templates from within other CloudFormation templates. It is possible to further abstract these hierarchical stacks by creating StackSets. StackSets require special AWS CloudFormation permissions, which are not required for conventional CloudFormation.

Terraform has more modularity than CloudFormation, which is a plus. Organizations can use pre-built Terraform modules from any of the supported providers or build their own from scratch.

CloudFormation, on the other hand, makes it difficult for customers to provide or natively integrate non-AWS resources in a multi-cloud or hybrid environment. Incorporating third-party resources or specialized AWS services that aren’t built into CloudFormation isn’t difficult, but it necessitates more coding and design work.


CloudFormation and Terraform use different approaches to handling parameters and settings. Terraform makes advantage of provider-specific data sources. Since it’s modular, it may be used in any Terraform configuration to fetch or compute data for use elsewhere. If you want to use an Elastic IP address to upgrade or provision infrastructure, you can do so with this feature. The maximum number of parameters in a CloudFormation template is 60. There must be a unique identifier for each argument in the template. CloudFormation parameters must be provided at stack runtime and must be of a supported type. The template itself must declare and refer to each parameter that is used. It is possible to use Dynamic References in CloudFormation to fetch parameters from the AWS Systems Manager parameter store if one is correctly configured.


Terraform employs the HashiCorp Configuration Language (HCL), a language developed by HashiCorp, to configure its infrastructure. It was designed to find a compromise between user and machine-friendly languages while still being understandable by humans and is fully compatible with JSON. JSON and YAML are both supported by AWS CloudFormation, with the YAML version being slightly more user-friendly (as well as more compact). The template body is similarly limited to 51,000 bytes in CloudFormation. AWS recommends that developers use stacked stacks if they need to create a larger template.


Both of these tools are completely free of charge. Both of these programmes have sizable user communities that provide a wealth of information, guidance, and inspiration. The act of cloud creation is free. CloudFormation users pay only for the AWS service that is provisioned by the service. Free and open-source, Terraform is a useful tool. Terraform, on the other hand, offers an enterprise-level edition for a fee that includes more tools for teamwork and management.

Integration of Multiple Clouds

Terraform is your best bet if you want to supply services on several cloud platforms. CloudFormation, on the other hand, only works with AWS, but Terraform can work with any cloud provider. A multi-cloud environment will not benefit from using Cloudformation. If you’re using AWS services like EC2, S3, and so forth, Cloudformation is the ideal option for you.

Terraform’s interoperability with AWS has been addressed in the newest version of the software. With this release, Terraform and CloudFormation are regarded as equal in their ability to handle AWS cloud resources.

Conclusion and Closing Thoughts

Both tools are extremely effective at managing cloud infrastructure. CloudFormation may be more efficient if you are currently on AWS and using all AWS capabilities, particularly if you have no external tie-ins from third parties. A cloud-agnostic framework that interfaces with AWS services (and those of all other prominent providers) like Terraform can be more useful if you need extra flexibility from a cloud-independent platform. We must consider not only the current state of any infrastructure but what it might look like in the future. Both toolsets have long-term advantages, and the ultimate verdict may come down to simple accessibility and developer comfort. No matter which AWS infrastructure tool you use, you’ll benefit from increased productivity, mobility, and efficiency with either of these “swiss army knives.” CloudFormation allows you to create custom resources. This can be done using Lambda functions. In the event that you have linked a function to a custom resource, the function will be called when the custom resource is created or changed. All the request data is passed to the function by calling the Lambda API from AWS CloudFormation (such as the request type and resource properties).

  • State: 
  •  CloudFormation: Preserves State into the CloudFormation stacks that you can see in the console.
      • Terraform: Saves the application states locally(or at a define place like an S3 bucket, a local folder or any other file storage service.
  • Language: 
    • CloudFormation: You can use either JSON or Yaml, being Yaml the common way to go. The Yaml support has support for certain rule, like joining string for example:

 Value: !Join 






  • Terraform: You will use the 
Dolan Cleary
Dolan Cleary

I am a recent graduate from the University of Wisconsin - Stout and am now working with AllCode as a web technician. Currently working within the marketing department.

Related Articles

Navigating AWS Complexity

Navigating AWS Complexity

Amazon’s Web Services is a very complex platform. Streamlining and optimizing production workflows can be challenging for inexperienced users. However, the benefit of learning grants options for better efficiency, reliability, security, and cost-effectiveness for operations run on AWS.

While complexity can be difficult to navigate, it’s not impossible. With the right level of expertise, AWS complexity can be navigated with ease.

What is Amazon Managed Grafana?

What is Amazon Managed Grafana?

Grafana stands out as a widely embraced open-source analytics and visualization platform, celebrated for its versatility in handling diverse data sources and delivering compelling dashboards and graphs. Renowned for its user-friendly interface, Grafana simplifies the process of data interpretation and enhances the overall experience by providing interactive visualizations.

AWS and re:Invent 2023

AWS and re:Invent 2023

There are plenty of AWS enthusiasts around the world such as ourselves with ideas on how to apply the Cloud in new and innovative ways. It’s a keynote where these enthusiasts come together, network, and share innovations and new methodologies with the public. Even for people less familiar with AWS, it is a great place to get first-hand experience with the platform either unguided or with professional help to see what opportunities the platform has.

Download our 10-Step Cloud Migration ChecklistYou'll get direct access to our full-length guide on Google Docs. From here, you will be able to make a copy, download the content, and share it with your team.