CloudConsole

AWS CDK vs CloudFormation

Updated 17 November 2026 · How we write and check guides

Short answer

The CDK is not an alternative engine: it generates CloudFormation templates from code and deploys them as stacks. Use the CDK when you build and maintain many resources and want constructs, loops, types and unit tests. Use plain CloudFormation (or AWS SAM) for small, stable templates, for StackSets and Service Catalog products, or when the people maintaining it do not write code.

AWS CDK vs CloudFormation: deciding factors Authoring, Output, Abstraction, Assets; When the CDK is worth it / When plain…
The deciding factors from this page's comparison table, and the cases where each option wins.

CDK vs CloudFormation compared

FactorAWS CDKCloudFormation templates
AuthoringTypeScript, JavaScript, Python, Java, C#/.NET or GoYAML or JSON
OutputSynthesised CloudFormation template plus assetsThe template itself
AbstractionL2/L3 constructs with defaults and grant helpersOne resource at a time; modules and macros for reuse
AssetsBundles Lambda code and Docker images automaticallyYou package and upload them (or use aws cloudformation package)
PrerequisitesBootstrap per account and Region; Node.js for the CLINone
Previewcdk diffChange sets
Deployment, state, rollbackCloudFormationCloudFormation
CostSame as CloudFormationNo charge for AWS resource types

When the CDK is worth it

  • Many similar services or environments: a construct encodes the pattern once.
  • You want IAM policies derived from relationships (table.grantReadWriteData(fn)) rather than written by hand.
  • Lambda and container assets built and uploaded as part of cdk deploy.
  • Infrastructure unit tests with assertions on the synthesised template.

Every CloudFormation resource is available as an L1 construct (named Cfn...), generated from the CloudFormation specification; new resources or properties can take up to a week to appear in the construct library. Escape hatches let you override any property on a higher-level construct.

When plain CloudFormation is better

  • A small, rarely changing stack: a few IAM roles, a bucket, an alarm.
  • Templates distributed to other teams or accounts through StackSets, Service Catalog or the console, where a readable template is the product.
  • Teams without a language toolchain in the pipeline, or a strict rule against generated templates.
  • Serverless apps where AWS SAM's short syntax is enough.

Moving between them

To adopt the CDK without redeploying, wrap an existing template with CfnInclude and refactor gradually; logical IDs stay the same so CloudFormation sees no replacement. To leave the CDK, run cdk synth and keep the generated template, though it will be harder to read than hand-written YAML. Avoid changing construct IDs during refactors: a changed logical ID means CloudFormation replaces the resource, which for a database or bucket can mean data loss unless it is retained.

Common wrong reasons

  • "The CDK removes CloudFormation's limits." Templates still have resource, parameter and output quotas, and deployments still go through stacks.
  • "CDK deploys faster." The deploy is CloudFormation either way; only authoring is faster.
  • "CloudFormation cannot reuse code." Modules, nested stacks and macros exist, though the CDK makes reuse easier.

Questions

Is the AWS CDK the same as CloudFormation?

No, but it uses it. The CDK is a framework that synthesises CloudFormation templates from code; CloudFormation then deploys and tracks the resources.

What is cdk bootstrap?

A one-time setup per account and Region that deploys a CloudFormation stack with an S3 bucket, an ECR repository and IAM roles the CDK uses to deploy.

Can I convert a CloudFormation template to CDK?

Yes. Use CfnInclude to import the template into a CDK app as-is, then refactor resources into higher-level constructs over time.

When this happens away from your desk

Whether the template came from CDK or YAML, a stuck rollback is debugged from stack events. CloudConsole is being built to show stack events and related alarms on a phone with production guardrails.

About the app → · Download on the App Store

Sources