0
0
Terraformcloud~5 mins

Terraform vs CloudFormation vs Pulumi - CLI Comparison

Choose your learning style9 modes available
Introduction
Managing cloud resources can be complex. Terraform, CloudFormation, and Pulumi help by letting you write code to create and update these resources automatically. They solve the problem of manual setup and keep your cloud organized and repeatable.
When you want to create and manage cloud resources like servers, databases, and networks using code.
When you need to keep your cloud setup consistent across different environments like testing and production.
When you want to track changes to your cloud setup safely and roll back if needed.
When you prefer using a specific language or tool that fits your team's skills and cloud provider.
When you want to automate cloud resource management to save time and reduce errors.
Commands
This command sets up Terraform in your project folder by downloading necessary plugins and preparing the environment.
Terminal
terraform init
Expected OutputExpected
Initializing the backend... Initializing provider plugins... - Finding latest version of hashicorp/aws... - Installing hashicorp/aws v4.0.0... - Installed hashicorp/aws v4.0.0 (signed by HashiCorp) Terraform has been successfully initialized!
This command shows what changes Terraform will make to your cloud resources without applying them yet. It helps you review before making changes.
Terminal
terraform plan
Expected OutputExpected
An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: + aws_instance.example id: <computed> Plan: 1 to add, 0 to change, 0 to destroy.
This command applies the planned changes to your cloud resources automatically without asking for confirmation.
Terminal
terraform apply -auto-approve
Expected OutputExpected
aws_instance.example: Creating... aws_instance.example: Creation complete after 10s [id=i-1234567890abcdef0] Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
-auto-approve - Skip manual approval to apply changes immediately
This command deletes all the resources Terraform created, cleaning up your cloud environment.
Terminal
terraform destroy -auto-approve
Expected OutputExpected
aws_instance.example: Destroying... aws_instance.example: Destruction complete after 5s Destroy complete! Resources: 1 destroyed.
-auto-approve - Skip manual approval to destroy resources immediately
Key Concept

If you remember nothing else, remember: Terraform, CloudFormation, and Pulumi let you manage cloud resources with code to automate and control your cloud setup safely.

Common Mistakes
Running terraform apply without running terraform plan first
You might apply unexpected changes without reviewing them, causing errors or downtime.
Always run terraform plan to see what will change before applying.
Not initializing Terraform with terraform init before other commands
Terraform won't have the necessary plugins and setup, causing errors.
Run terraform init once when starting a new project or after changing providers.
Forgetting to destroy resources after testing
Unused cloud resources can cost money and clutter your environment.
Use terraform destroy to clean up resources when no longer needed.
Summary
terraform init prepares your project by downloading needed plugins.
terraform plan shows what changes will happen without applying them.
terraform apply makes the planned changes to your cloud resources.
terraform destroy removes all created resources to clean up.