Skip to main content

What's the Difference Between AWS CDK and AWS SAM?

Compare AWS CDK and AWS SAM side by side — features, pricing, and ideal use cases to help you choose the right product.

Compare side-by-side

Comparisons
AWS CDK
AWS SAM
Category

Developer Tools, Infrastructure as code

Serverless, Framework

Description

Infrastructure-as-code framework to model cloud resources

Open-source framework for building serverless applications with shorthand syntax for functions, APIs, and event sources.

Best for
  • Infrastructure as code
  • Application scaffolding
  • Reusable constructs
  • Multi-stack deployments
  • Serverless development
  • Local testing
  • CI/CD for serverless
  • Infrastructure as code
Key features
  • Multiple languages
  • Constructs library
  • CDK Pipelines
  • Asset bundling
  • Testing support
  • SAM CLI
  • Local testing
  • CloudFormation extension
  • Policy templates
  • Accelerate deployments
Pricing model

No additional charge; pay for resources created

No additional charge; pay for underlying resources

Free tier

Yes

Yes

Expert take

“CDK lets developers define infrastructure in the same language as their application, with IDE autocomplete and type safety. L2 and L3 constructs encode AWS best practices (encryption, logging, least-privilege) by default. CDK Pipelines builds self-mutating CI/CD that deploys both app and infra changes.”
— Gary McLean, re:Post Top Contributor [profile]

“SAM extends CloudFormation with serverless-specific shorthand. A single SAM function definition generates the Lambda function, IAM role, API Gateway endpoint, and event source.”
— Giovanni Lauria, re:Post Top Contributor [profile]

Product page

When to use AWS CDK or AWS SAM

Use AWS CDK when:

  • Infrastructure as code
  • Application scaffolding
  • Reusable constructs
  • Multi-stack deployments

Learn more about AWS CDK »

Use AWS SAM when:

  • Serverless development
  • Local testing
  • CI/CD for serverless
  • Infrastructure as code

Learn more about AWS SAM »

AWS product comparisons

Did you find what you were looking for today?

Let us know so we can improve the quality of the content on our pages