CloudConsole

CloudFormation vs Terraform

Updated 17 November 2026 · How we write and check guides

Short answer

Choose CloudFormation if you are AWS-only and want AWS to hold state, roll back failed deployments automatically and deploy across accounts with StackSets, at no extra charge for AWS resources. Choose Terraform if you manage more than AWS (other clouds, SaaS such as GitHub, Datadog or Cloudflare), want one workflow and module ecosystem for all of it, and are prepared to run and secure remote state.

CloudFormation vs Terraform: deciding factors Language, State, Preview, Failure handling; When CloudFormation is the better…
The deciding factors from this page's comparison table, and the cases where each option wins.

CloudFormation vs Terraform compared

FactorAWS CloudFormationHashiCorp Terraform
LanguageJSON or YAML templatesHCL (Terraform language)
StateManaged by AWS in the stackState file you store and lock (for example in S3), may contain secrets
PreviewChange setsterraform plan
Failure handlingAutomatic rollback to last working stateStops; partially applied changes remain until you fix and re-apply
ScopeAWS (plus registry and custom resources)AWS and hundreds of other providers
Multi-account rolloutStackSets across accounts and RegionsWorkspaces, pipelines or wrappers you build
DriftDrift detection on stacksplan shows drift against state
CostNo charge for AWS::*, Alexa::* and Custom::* resources; third-party handlers billedCLI free to use; HCP Terraform or Enterprise priced separately
LicenceAWS serviceBusiness Source License since August 2023

When CloudFormation is the better choice

  • Everything you manage is on AWS and you want no state infrastructure to look after.
  • You value automatic rollback: a failed update returns the stack to its previous state rather than leaving it half applied.
  • Organisation-wide guardrails and baselines deployed to every account through StackSets or Control Tower.
  • You use AWS SAM or the AWS CDK, which both deploy through CloudFormation.

Watch the quotas: a template can declare 500 resources, 200 parameters and 200 outputs. Large systems split into nested or separate stacks connected with exports or SSM parameters.

When Terraform is the better choice

  • Multi-cloud or hybrid estates, or heavy use of SaaS providers that have Terraform providers.
  • Teams that prefer HCL modules and a plan-then-apply review in pull requests.
  • You want to import and refactor existing resources freely, moving them between modules with moved and import blocks.

Treat state as sensitive: AWS prescriptive guidance recommends storing it remotely, encrypted and versioned, with least-privilege access, because it can hold database passwords and other secrets.

Migrating or mixing

You can run both, but give each resource exactly one owner. A common split is CloudFormation or Control Tower for account baselines and Terraform for application infrastructure, or the reverse. To move resources from CloudFormation to Terraform, set DeletionPolicy: Retain, remove them from the stack, then terraform import them. To move the other way, CloudFormation resource import brings existing resources into a stack, and the IaC generator can produce a template from resources in your account.

Common wrong reasons

  • "Terraform supports new AWS features faster." It depends on the feature and provider release. AWS notes Terraform may lag; CloudFormation can also lag for some services. Check the specific resources you need.
  • "CloudFormation is too verbose." Raw YAML is; the CDK generates it for you if you prefer code.
  • "Terraform is open source." Its licence changed to the Business Source License in 2023; check whether that matters for how you use it.

Questions

Is Terraform better than CloudFormation for AWS?

Neither is better in general. CloudFormation suits AWS-only teams that want managed state and automatic rollback; Terraform suits teams managing several providers with one tool.

Does CloudFormation cost anything?

There is no charge for AWS::*, Alexa::* and Custom::* resources; you pay for the resources created. Third-party resource types from the registry incur handler operation charges.

Can Terraform and CloudFormation manage the same account?

Yes, as long as each resource is managed by only one of them. Shared values can be passed through SSM parameters or stack outputs read by Terraform data sources.

When this happens away from your desk

A failed deploy at night looks different in each tool: a stack stuck in UPDATE_ROLLBACK_FAILED versus a Terraform apply that stopped halfway. CloudConsole is being built to show stack events, alarms and recent changes on a phone with production guardrails.

About the app → · Download on the App Store

Sources