03/06/24

Terraform: A guide for 2024

A look at Features, Limitations, and Alternatives

6 Min Read

Over the past few years Terraform has become the status quo in the Infrastructure as Code (IaC) landscape. It lets developers and DevOps engineers define and provision their infrastructure through writing Terraform configuration files using the HashiCorp Configuration Language (HCL).

But should you use it in 2024? Let’s unpack the main use cases, the pros and cons of Terraform, and its implications on developer experience and cloud cost management.

What is Terraform?

At its core, Terraform is an open-source tool used to build, modify, and version control infrastructure. It supports several service providers, enabling the creation of customized deployments. Terraform operates on the principle of Infrastructure as Code (IaC), where infrastructure is declared as code. This means it can be shared, reviewed, and controlled just like any other software codebase.

Key Terraform Use Cases

  1. Multi-Cloud Deployment: Terraform helps with deploying applications across multiple cloud providers. With it, you can use the same tool and similar syntax to manage resources in AWS, GCP, Azure, and many others.
  2. Microservices Infrastructure: Terraform can manage the infrastructure requirements of a microservices architecture, efficiently provisioning resources for each individual service.
  3. Managing Diverse Cloud Resources: Terraform isn't limited to server management. It can also handle databases, DNS entries, and most other resources offered by a cloud provider.

The Upside of Using Terraform

  • 1. Provider Agnostic: Terraform supports an impressive range of Terraform providers, including major cloud providers and many other services, making it a versatile choice for IaC needs.
  • 2. Modularity: Terraform promotes the use of Terraform modules, helping you create reusable components that can be shared across your organization.
  • 3. Version Control Capabilities: Since infrastructure is represented as code, it can be versioned and tracked using conventional version control systems like Git.

The Drawbacks of Terraform

  • 1. Drift in State Management: Terraform must keep track of the current state of your resources. Managing this state file, in a codebase entirely separate from the application code, can be problematic in a large team setting – especially as individuals will often circumvent the process by making changes directly in the cloud provider's console. This often causes "drift", meaning the configuration file does not match reality.
  • 2. Learning Curve: Terraform uses a proprietary syntax, HashiCorp Configuration Language (HCL), for infrastructure configuration. This can be challenging for beginners and comes with a steep learning curve. Moreover, it requires a lot of experience with each cloud provider's services to ensure proper configuration.
  • 3. Significant Effort in Environment Setup: Configuration needs to be manually replicated for different environments, which is often time-consuming and error-prone. The scope involved often leads to teams relying on 1:1 duplicates of production for dev and staging environments. This causes expensive over-provisioning of these environments, significantly increasing cloud costs.
  • 4. Debugging Errors: Debugging and error handling can be complex, especially with large deployments.
  • 5. Disconnect Between Developers and DevOps: Developers, typically not versed in HCL, are often forced to rely on DevOps to provision resources, often slowing down the development process.

Alternatives to Terraform

Encore

Encore Interface

Encore is a modern alternative, aimed at teams looking for a more developer-centric and cohesive approach to infrastructure management. It works by providing an Infrastructure SDK that lets developers declare infrastructure as part of the application code, in a cloud-agnostic way. This avoids many of the drawbacks of Terraform, by keeping both application code and infrastructure declarations in one code base and one programming language.

Benefits & Key Features

  • Cross-cloud Support: Encore makes applications cloud-portable by default, and lets you deploy your application to both AWS and GCP without any code changes.
  • Preview Environments: Encore provides automated Preview Environments for each Pull Request, making it simple to validate changes with faster feedback loops.
  • Developer Experience: Encore focuses on simplifying development by removing boilerplate and unlike Terraform does not require you to manually write infrastructure configuration in a proprietary language.
  • Built-in Distributed Tracing: Applications built with Encore are automatically instrumented with distributed tracing and key performance metrics, aiding in debugging and performance monitoring.

Limitations

  • Language specific: With Encore your application code and infrastructure declarations are all in the same programming language. The drawback is that not all programming languages are supported yet. Currently Encore supports Go and TypeScript.

Suitable For

Teams that want to concentrate on developing their application and prefer not to spend time on complex DevOps processes and manual setup of their infrastructure.

When to consider Encore

Try Encore

AWS CloudFormation

AWS CloudFormation is an IaC service specifically designed for AWS. It uses YAML or JSON templates to create and manage AWS resources.

Benefits & Key Features

  • AWS-Specific: Deep integration with AWS services.
  • Template-Based Configuration: Reusable code components.

Limitations

  • No Multi-Cloud Support: Confined to AWS, limiting cross-platform applications.
  • Cloud Lock-in: CloudFormation only works with AWS and often leads to significant cloud lock-in effects which can lead to increased costs and reduced flexibility over time.
  • Language: JSON and YAML might be less readable for some compared to Terraform's HCL.

Suitable For

Organizations that are heavily invested in AWS and require native integration and management of AWS resources.

Google Cloud Deployment Manager (CDM)

Google Cloud Deployment Manager is an IaC tool specifically for Google Cloud Platform, using YAML-based configuration.

Benefits

  • Google Cloud Specific: Tailored for GCP, ensuring seamless integration.
  • YAML-Based Configuration: Offers consistency and structure.

Limitations

  • Limited to GCP: Does not support other cloud platforms.
  • Cloud Lock-in: Google CDM only works with GCP and often leads to significant cloud lock-in effects which can lead to increased costs and reduced flexibility over time.
  • Less Community Support: May not have as extensive community support as Terraform.

Suitable For

Organizations using Google Cloud Platform exclusively, looking for an integrated solution to manage their resources.

Azure Resource Manager

Azure Resource Manager is designed for Microsoft's Azure platform, offering robust management of Azure resources through JSON-based templates.

Benefits

  • Azure-Specific: Deeply integrated with Azure's suite of tools and services.
  • Structured Templates: Promotes reusable and maintainable code.

Limitations

  • No Support for Multi-Cloud: Confined to Azure, hindering cross-platform application.
  • Cloud Lock-in: Azure Resource Manager only works with Azure and often leads to significant cloud lock-in effects which can lead to increased costs and reduced flexibility over time.
  • Complexity: Can be challenging to learn, particularly for those new to Azure.

Suitable For

Businesses committed to Azure, seeking a powerful tool to orchestrate and manage their Azure resources effectively.

Conclusion

Terraform undoubtedly brings several benefits to the table, from multi-cloud support to enforcing consistent environments. However, the manual and complex nature of its configuration, the gap between application developers and DevOps, and cost considerations may make alternatives worth considering. Understanding the trade-offs is essential in making an informed choice that suits your project's needs and budget constraints.

Ready to escape the hamster wheel?

Encore is Backend Development Platform purpose-built for creating event-driven and distributed systems — from developing locally to scaling in your cloud on AWS/GCP.