Bird
Raised Fist0
Terraformcloud~10 mins

Terraform vs CloudFormation vs Pulumi - Visual Side-by-Side Comparison

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Process Flow - Terraform vs CloudFormation vs Pulumi
Start: Choose IaC Tool
↓
Deploy Infrastructure
↓
Manage State & Updates
↓
Infrastructure Ready
The flow shows choosing between Terraform, CloudFormation, or Pulumi, then deploying and managing infrastructure.
Execution Sample
Terraform
terraform {
  required_providers {
    aws = { source = "hashicorp/aws" version = "~> 4.0" }
  }
}
resource "aws_s3_bucket" "example" {
  bucket = "my-unique-bucket-12345"
}
This Terraform code creates an AWS S3 bucket named 'my-unique-bucket-12345'.
Process Table
StepActionTool BehaviorResult
1Initialize TerraformReads config, downloads AWS providerReady to plan
2terraform planCompares desired state with currentShows bucket to create
3terraform applyCreates S3 bucket in AWSBucket 'my-unique-bucket-12345' created
4CloudFormation equivalentUses JSON/YAML templateCreates same bucket in AWS
5Pulumi equivalentUses code in Python/JS/etc.Creates same bucket in AWS
6Manage updatesTerraform tracks state fileUpdates or deletes resources as needed
7ExitInfrastructure deployed and managedReady for use
💡 Infrastructure is deployed and managed by the chosen tool.
Status Tracker
VariableStartAfter InitAfter PlanAfter ApplyFinal
terraform_stateemptyinitializedplanned (bucket to create)applied (bucket created)current state with bucket
aws_s3_bucket.examplenonedefined in configplanned for creationcreated in AWSexists and ready
Key Moments - 3 Insights
Why does Terraform use a state file while CloudFormation does not?
Terraform keeps a local or remote state file to track resources across clouds, while CloudFormation manages state internally within AWS. See execution_table rows 6 and 4.
Can Pulumi use the same languages as Terraform?
No, Pulumi uses general-purpose languages like Python or JavaScript, while Terraform uses its own HCL language. See concept_flow and execution_table rows 5 and 1.
Why choose CloudFormation over Terraform?
CloudFormation is AWS-native and may have faster support for new AWS features. Terraform supports multiple clouds but may lag. See concept_flow and execution_table rows 4 and 1.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step is the S3 bucket actually created in AWS?
AStep 3
BStep 4
CStep 2
DStep 6
💡 Hint
Check the 'Result' column for when the bucket is created.
According to variable_tracker, what is the state of 'terraform_state' after 'terraform plan'?
Aempty
Binitialized
Cplanned (bucket to create)
Dapplied (bucket created)
💡 Hint
Look at the 'After Plan' column for 'terraform_state'.
If you want to use Python code to define infrastructure, which tool from concept_flow would you pick?
ACloudFormation
BPulumi
CTerraform
DNone of these
💡 Hint
See the 'Pulumi' box in concept_flow mentioning general languages.
Concept Snapshot
Terraform, CloudFormation, and Pulumi are tools to create cloud infrastructure.
Terraform uses HCL and supports many clouds.
CloudFormation is AWS-only and uses JSON/YAML.
Pulumi uses real programming languages and supports many clouds.
All deploy resources and manage updates differently.
Full Transcript
This visual execution compares Terraform, CloudFormation, and Pulumi. It starts with choosing a tool, then shows Terraform code creating an AWS S3 bucket. The execution table traces initialization, planning, applying, and managing infrastructure. Variable tracking shows how Terraform state and resource definitions change step-by-step. Key moments clarify differences in state management, language use, and cloud support. The quiz tests understanding of when resources are created, state changes, and tool language options. The snapshot summarizes key points for quick recall.

Practice

(1/5)
1. Which infrastructure as code tool is designed to work only with AWS and uses JSON or YAML for its templates?
easy
A. CloudFormation
B. Terraform
C. Pulumi
D. Ansible

Solution

  1. Step 1: Identify AWS-only tool

    CloudFormation is the only tool among the options that works exclusively with AWS.
  2. Step 2: Check template language

    CloudFormation uses JSON or YAML for its templates, unlike Terraform (HCL) or Pulumi (programming languages).
  3. Final Answer:

    CloudFormation -> Option A
  4. Quick Check:

    AWS-only + JSON/YAML = CloudFormation [OK]
Hint: AWS-only and JSON/YAML means CloudFormation [OK]
Common Mistakes:
  • Confusing Terraform as AWS-only
  • Thinking Pulumi uses JSON/YAML
  • Selecting Ansible which is not IaC focused
2. Which of the following is the correct way to describe Pulumi's approach to infrastructure as code?
easy
A. Uses general-purpose programming languages like JavaScript or Python
B. Uses JSON or YAML templates tightly integrated with AWS
C. Uses shell scripts for provisioning
D. Uses a domain-specific language called HCL

Solution

  1. Step 1: Identify Pulumi's language style

    Pulumi uses real programming languages such as JavaScript, Python, Go, or C# for defining infrastructure.
  2. Step 2: Eliminate other options

    HCL is Terraform's language, JSON/YAML with AWS is CloudFormation, and shell scripts are not Pulumi's approach.
  3. Final Answer:

    Uses general-purpose programming languages like JavaScript or Python -> Option A
  4. Quick Check:

    Pulumi = real programming languages [OK]
Hint: Pulumi uses real programming languages, not templates [OK]
Common Mistakes:
  • Confusing Pulumi with Terraform's HCL
  • Thinking Pulumi uses JSON/YAML
  • Assuming Pulumi uses shell scripts
3. Given the following statements, which tool supports multiple cloud providers and uses a simple declarative language called HCL?
1. Supports AWS, Azure, GCP
2. Uses JSON or YAML
3. Uses HCL
4. Uses programming languages like TypeScript
medium
A. Chef
B. Pulumi
C. CloudFormation
D. Terraform

Solution

  1. Step 1: Match multi-cloud support

    Terraform supports multiple clouds like AWS, Azure, and GCP.
  2. Step 2: Match language used

    Terraform uses HCL, a simple declarative language. JSON/YAML is CloudFormation, programming languages like TypeScript is Pulumi.
  3. Final Answer:

    Terraform -> Option D
  4. Quick Check:

    Multi-cloud + HCL = Terraform [OK]
Hint: Multi-cloud + HCL means Terraform [OK]
Common Mistakes:
  • Choosing Pulumi for HCL language
  • Selecting CloudFormation for multi-cloud
  • Confusing Chef with IaC tools
4. You wrote a Pulumi program in Python but it fails to deploy because it uses AWS-specific resource names not supported by Azure. What is the main error here?
medium
A. Terraform should be used instead of Pulumi for AWS
B. Pulumi does not support Python as a language
C. Using AWS resource names in a multi-cloud Pulumi program without adjusting for Azure
D. CloudFormation templates are required for Azure deployments

Solution

  1. Step 1: Identify the cause of failure

    The Pulumi program uses AWS resource names but tries to deploy on Azure, causing incompatibility.
  2. Step 2: Understand Pulumi's multi-cloud nature

    Pulumi supports multiple clouds but resource names and APIs differ per cloud and must be adjusted accordingly.
  3. Final Answer:

    Using AWS resource names in a multi-cloud Pulumi program without adjusting for Azure -> Option C
  4. Quick Check:

    Cloud-specific resource names must match target cloud [OK]
Hint: Match resource names to target cloud in Pulumi [OK]
Common Mistakes:
  • Thinking Pulumi can't use Python
  • Believing Terraform is required for AWS
  • Assuming CloudFormation works on Azure
5. You want to manage infrastructure across AWS and Azure using a single tool. You prefer writing code in TypeScript and want to reuse existing programming skills. Which tool should you choose and why?
hard
A. CloudFormation, because it is tightly integrated with AWS
B. Pulumi, because it supports multiple clouds and uses real programming languages like TypeScript
C. Terraform, because it supports multiple clouds and uses HCL
D. Ansible, because it uses YAML for automation

Solution

  1. Step 1: Identify multi-cloud support with TypeScript

    Pulumi supports multiple clouds and allows writing infrastructure code in TypeScript, matching the requirement.
  2. Step 2: Compare other tools

    Terraform supports multi-cloud but uses HCL, not TypeScript. CloudFormation is AWS-only. Ansible is for automation, not primarily IaC with TypeScript.
  3. Final Answer:

    Pulumi, because it supports multiple clouds and uses real programming languages like TypeScript -> Option B
  4. Quick Check:

    Multi-cloud + TypeScript = Pulumi [OK]
Hint: Multi-cloud + TypeScript means Pulumi [OK]
Common Mistakes:
  • Choosing Terraform for TypeScript support
  • Selecting CloudFormation for multi-cloud
  • Confusing Ansible with IaC tools