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
|
|
|
|
Key features
|
|
|
|
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.” |
“SAM extends CloudFormation with serverless-specific shorthand. A single SAM function definition generates the Lambda function, IAM role, API Gateway endpoint, and event source.” |
|
Product page
|
When to use AWS CDK or AWS SAM
Use AWS CDK when:
- Infrastructure as code
- Application scaffolding
- Reusable constructs
- Multi-stack deployments
Use AWS SAM when:
- Serverless development
- Local testing
- CI/CD for serverless
- Infrastructure as code
Next steps with AWS for Developer Tools
AWS product comparisons
Read about AWS products side-by-side
Did you find what you were looking for today?
Let us know so we can improve the quality of the content on our pages