🎓 A1Learner
🔍
0 of 50 lessons completed

Terraform vs Ansible vs CloudFormation vs Pulumi

Terraform, Ansible, CloudFormation and Pulumi are four tools that manage infrastructure in different ways. Each one fits a different job.

The comparison in one table

Read across each row to see what the tool does best.

Tool           | Main job              | Cloud limit
---------------|-----------------------|------------
Terraform      | Provision resources   | Many clouds
Ansible        | Configure machines    | Many clouds
CloudFormation | Provision resources   | AWS only
Pulumi         | Provision resources   | Many clouds

Provisioning and configuring

Provisioning creates the machine. Configuring prepares it for work.

# Terraform creates the server.
resource "local_file" "server" {
  filename = "server.txt"
  content  = "A new server."
}

# Ansible would then install programs on it.

One language, many clouds

Terraform uses one language for many providers. CloudFormation uses AWS only.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "6.72.0"
    }
  }
}

Example

# The same idea, in each tool's own job:
# Terraform: create a storage bucket.
# Ansible: install a web server on a machine.
# CloudFormation: create a storage bucket on AWS only.
# Pulumi: create a storage bucket using Python code.

# Terraform example:
resource "local_file" "bucket_note" {
  filename = "bucket.txt"
  content  = "A bucket would be created here."
}

Key points

  • Terraform provisions infrastructure, which means it creates servers, networks and storage.
  • Ansible configures machines, which means it installs programs and changes settings inside them.
  • CloudFormation works only with AWS, so it cannot manage other clouds in the same file.
  • Pulumi lets you write infrastructure in a real programming language, such as Python or TypeScript.
  • Terraform works with many clouds and services from one language.
  • Teams often use Terraform and Ansible together, one to create and one to configure.

Each tool has one main job. Terraform creates the resource. Ansible would prepare the machine after it exists. The choice depends on the job, not on which tool is newer.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

Which tool configures machines by installing programs and changing settings inside them?