CloudFormation vs. Terraform

Β 
Β 

CDK vs. CloudFormation vs. Terraform vs. Pulumi
CDK vs. CloudFormation vs. Terraform vs. Pulumi

When you want to implement infrastructure as code, you always come to the question if you should use CloudFormation or HashiCorp's open-source tool Terraform. Both have their advantages and disadvantages. I compared both in the following table to help you decide which tool is best suited for your needs.

Update

Since there was a lot of feedback that you would like to have a comparison including the AWS CDK, I expanded the table by one column for the AWS CDK. I hope the table will help you to make the decision for the right tool for you.

⁉️ Some people asked me to add Pulumi as well to the table - here is your update πŸš€.

Feature
AWS CDK
AWS CDK
CloudFormation
Cloudformation
Terraform
Terraform
Pulumi
Pulumi
Supported AWS Resources 500+ 500+ 400+ 400+
Integration of new features after announcement βž–
After announcement of a new feature there is always a delay until it is integrated into CDK, but you can use Escape Hatches to workaround these missing features.
βž–
After announcement of a new feature there is always a delay until it is integrated into CloudFormation, but as a workaround you can develop custom resources to cover new features.
βž– After announcement of a new feature there is always a delay until it is integrated into Terraform, but as a workaround you can use terraform-aws-anything to cover new features. βž– After announcement of a new feature there is always a delay until it is integrated into Pulumi.
License and Support βž–
Open-source with support from AWS.
βž–
Free with support from AWS and large community.
βž–
Open-source with support from Hashicorp and large community.
βž–
Open-source with support from Pulimi and large community.
Third Party βœ…
CDK supports third-party resources.
βœ…
CloudFormation supports third-Party vendors to create resource providers.
βœ…
Terraform supports third-party providers and provisioners.
βœ…
Pulumi supports third-party providers.
CLI βœ…
CDK CLI enables you to list the stacks defined in your CDK app, synthesize the stacks into CloudFormation templates, determine the differences between running stack instances and the stacks defined in your CDK code and deploy stacks to any public AWS Region.
βœ…
CloudFormation has a CLI that enables you to develop and test AWS and third-party resources and register them for use in AWS CloudFormation.
βœ…
Terraform has a single command-line application.
βœ…
Pulumi has a single command-line application.
Language βœ…
Supports multiple programming languages Typescript, Javascript, Python, Java, and C#
βž–
JSON / YAML - YAML is easier to read than JSON but it forces you to have multiple nested scopes.
βœ…
HCL is human readable as well as machine-friendly.
βœ…
Supports multiple programming languages Typescript, Javascript, Python, Go - in preview, and C# - in preview
Modularization βœ…
CDK supports modules to create a reproducible infrastructure.
βž–
Nested stacks and cross-stack references can be used to achieve modularization.
βœ…
Terraform modules help to create a reproducible infrastructure.
βœ…
Pulumi modules help to create a reproducible infrastructure.
State Management βœ…
Deploys CloudFormation Stacks to manage its state.
βœ…
Uses Stacks to manage its state.
βœ…
By default saves the state locally but it is possible to save the state in Terraform Cloud, S3 or DynamoDB with the remote state feature.
βœ…
Pulumi saves the state (called checkpoint) locally but it is possible to save the state in Pulumi service backend or S3.
Configuration βœ…
Supports Environment Variables, CloudFormation Parameters or you can get values from SSM.
βœ…
Supports up to 60 Parameters. Import values from output of another stack or import from SSM.
βœ…
Data sources allow data to be fetched or computed for use elsewhere in Terraform configuration.
βœ…
Pulumi offers a Config object with various getters and setters for retrieving values, in addition they have Data sources that allow to grep, for example an AMI or an AZ from AWS.
Change management βœ…
cdk diff compares the desired state against the stack but it doesn't look at the deployed resources until you deploy. You only find out about discrepancies between the stack and deployed resources at deployment time.
βœ…
Change Sets help you to verify changes before you apply them on your stack.
βœ…
terraform plan creates a detailed execution plan before applying your changes.
βœ…
pulumi preview previews your changes explicitly before deploying.
Error handling and rollback βœ…
AutoRollbackConfig helps you to configure the behavior of automatically rolling back for a given Deployment Group.
βœ…
CloudFormation automatically rolls back to the last working state.
❌ ❌
Currently there is no rollback functionality in Pulumi but there is an open RFC to implement this functionality.
Import Existing Resources ❌
Currently its not possible to import resources into CDK, but there is an open RFC to implement this functionality. Additional information - there are workarounds how to use existing resources in CDK.
βž–
It is possible to import resources into CloudFormation but only for a few resources.
βž–
It is possible to import resources into terraform but it does not generate configuration.
βœ…
Pulumi offers an import resource option to request that a resource defined in your Pulumi program adopts an existing resource in the cloud provider instead of creating a new one.
Rolling updates for Auto-Scaling Groups βœ… βœ… βœ…
You can implement rolling updates for Auto-Scaling Groups using the create before destroy lifecycle policy.
βœ…
You can implement rolling updates for Auto-Scaling Groups using the createBeforeDestroy lifecycle policy.
External waiting conditions βœ…
You can use CfnWaitCondition to coordinate resource creation with configuration actions that are external to the stack creation.
βœ…
You can use WaitCondition to coordinate resource creation with configuration actions that are external to the stack creation.
βœ…
You can use null_resource to coordinate resource creation with configuration actions that are external to native Terraform resources.
βœ…
You pass a customTimeouts object as part of resource options to coordinate resource creation with configuration actions that are external to the resource.
Drift Detection βœ… βœ… βœ… βœ…
Visualization of dependencies βœ…
CDK has a plugin for Visual Studio Code which visualizes dependencies or you can use the cli.
βœ…
You can use the AWS CloudFormation Designer to view CloudFormation templates.
βœ…
You can use the terraform graph command to generate a visual representation of either a configuration or execution plan.
βœ…
You can use pulumi stack graph to export a stack’s dependency graph to a file.
Multi-Cloud Management ❌ ❌ βœ… βœ…


Β Β Β Β Β Β 

Cross-Account CI/CD Pipeline for ECS and Lambda

Automate your software delivery process using continuous integration and delivery (CI/CD) pipelines

Β 

Mar 24th 2020

Β 

Mohammed Yahya

AWS Codepipeline Notification

A simple notification application sending different statuses of your AWS CodePipeline to Slack or MS Teams using an incoming Webhook.

Β 

Mar 18th 2020

Β 

Walter Kopp

Shortcuts for AWS Infrastructure Automation

For some AWS services you can use the AWS console UI for guidance and creating the first version and almost extract most of the automation

Β 

Jan 15th 2020

Β 

MJ