Terraform Killer — Pulumi

Daniel Foo
4 min readNov 16, 2023

--

Terraform has been a popular choice as infrastructure as code (IaC) tool. However the Terraform is far from perfect.

For users new to infrastructure as code or declarative languages, there may be a learning curve associated with understanding Terraform’s HCL and its concepts. Some users find that Terraform’s HCL, while expressive, lacks certain programming features, and the abstraction level might not be as high as desired for complex scenarios.

Managing and versioning Terraform state files can be challenging, especially in team environments. Remote state storage is recommended for collaboration, but it introduces its own set of challenges. In some cases, new features or services provided by cloud providers may take some time to be supported in Terraform, leading to a potential lag in adopting the latest cloud capabilities.

Error messages from Terraform can sometimes be cryptic, making it challenging for users to troubleshoot issues, especially for those new to the tool. Protecting the Terraform state file is crucial for security, and if not handled properly, it can pose a risk. Remote state storage solutions must be properly configured for security.

So, what’s the solution?

Here comes the challenger, Pulumi.

Pulumi and Terraform are both infrastructure as code (IaC) tools that allow you to define, deploy, and manage infrastructure in a declarative manner. However, there are some key differences between the two. Below is a comparison of Pulumi and Terraform based on various aspects:

Language Support

Pulumi supports multiple programming languages, including JavaScript, TypeScript, Python, Go, and .NET. This allows you to use the language with which you are most comfortable.

Terraform uses its own domain-specific language (DSL), HashiCorp Configuration Language (HCL), which is designed specifically for infrastructure provisioning.

Declarative vs. Imperative

Pulumi is more imperative, meaning you describe the desired state of your infrastructure using a programming language. You write code that directly manipulates resources and their configurations.

Terraform follows a declarative approach. You define the desired end state of your infrastructure, and Terraform determines how to achieve that state.

Ease of Learning

Developers familiar with programming languages like JavaScript, TypeScript, Python, etc., may find Pulumi more natural to work with due to its use of general-purpose languages.

import com.pulumi.pulumi;
import com.pulumi.aws.s3.Bucket;

public class MyS3Bucket extends pulumi.ComponentResource {
// Constructor for the MyS3Bucket class
public MyS3Bucket(String name) {
super("my:example:MyS3Bucket", name);

// Create an AWS S3 bucket
Bucket bucket = new Bucket(name, BucketArgs.builder()
.acl("private") // Access control for the bucket (private in this case)
.build());

// Export the bucket name
this.export("bucketName", bucket.id());
}
}

Terraform’s HCL is designed to be relatively easy to read and write, making it accessible to users with minimal programming experience.

Community and Ecosystem

While Pulumi has a growing community, Terraform has been around for a longer time and has a larger and more established user base. Terraform also has a rich ecosystem of providers that support a wide range of cloud and on-premises services.

Terraform has a robust and mature ecosystem with a large number of providers for various cloud platforms and services.

State Management

Pulumi stores state information in a backend service or as a file in the project directory. You have flexibility in choosing where to store the state.

Terraform also stores state information, typically in a remote backend such as AWS S3 or HashiCorp Consul.

Continuous Deployment

Pulumi has built-in support for continuous deployment workflows, making it easier to integrate with CI/CD pipelines.

Terraform can be integrated into CI/CD pipelines, but some additional scripting may be required for certain advanced scenarios.

Maturity

Pulumi is a relatively newer entrant in the IaC space compared to Terraform.

Terraform has been around since 2014 and is widely adopted in the industry, indicating a higher level of maturity.

More about Pulumi

Pulumi allows you to use general-purpose programming languages for defining infrastructure, which means you have access to full language features. This can be particularly advantageous for complex infrastructure scenarios or for teams with strong programming backgrounds.

Pulumi comes with built-in testing capabilities, allowing you to write tests for your infrastructure code. This helps ensure the correctness of your configurations and catch potential issues before deployment.

Pulumi is designed to integrate seamlessly with continuous integration and continuous deployment (CI/CD) pipelines. This facilitates the automation of the deployment process, making it easier to incorporate infrastructure changes into your development workflows.

Pulumi’s approach is often described as “Infrastructure as Software,” emphasizing the use of programming languages and software development practices for managing infrastructure. This can lead to a more natural and integrated development experience.

In summary, Pulumi offers a unique set of advantages, especially for teams that value the use of general-purpose programming languages, desire a higher level of abstraction, and appreciate the benefits of a more programmatic and flexible approach to infrastructure management. The choice between Pulumi and other IaC tools often depends on specific project requirements and team preferences.

--

--

Daniel Foo
Daniel Foo

Written by Daniel Foo

Director of Engineering | MBA | Developer, Writer

Responses (9)