Install any skill in seconds. Free to start, no credit card required.
Get Started Free →AWS SAM and CDK guidance for scaffolding, templating, deploying, and CI/CD of serverless applications on AWS.
Use this skill ↓78% 83%+4 ptsof test cases passed
Passed 19 of 23 test cases with the skill, and 18 of 23 without it.
3 of 3 safety checks passed
Not used yet
Most teams don't switch from SAM to CDK all at once. Both tools produce CloudFormation templates, so they can coexist in the same project, the same account, and even the same CI/CD pipeline. SAM CLI works with any CloudFormation template, whether it uses the SAM transform or is synthesized by CDK.
The lowest-risk approach is to add CDK alongside SAM rather than replacing it:
sam build && sam deployCross-stack references between SAM and CDK stacks work the same way as any CloudFormation cross-stack reference: export a value from one stack, import it in the other via Fn::ImportValue (SAM) or cdk.Fn.importValue() (CDK). Alternatively, write values to SSM Parameter Store and read them from either side.
SAM CLI can build and locally test functions defined in any CloudFormation template, including one synthesized by CDK:
# Synthesize the CDK app to cdk.out/
cdk synth
# Use SAM CLI to build the synthesized template
sam build --template cdk.out/MyStack.template.json
# Test a function locally
sam local invoke MyFunction --template cdk.out/MyStack.template.json
This gives you CDK's construct model for infrastructure while using SAM CLI's sam local invoke for local testing.
| Scenario | Recommendation |
|---|---|
| New Lambda-centric project, small team | SAM — simpler templates, straightforward workflow |
| New project with complex infrastructure (VPCs, multiple services) | CDK — richer abstractions, grant* methods |
| Existing SAM project, works fine | Keep SAM — migration cost isn't justified |
| Existing SAM project, hitting limits (no loops, hard to share constructs) | Migrate incrementally to CDK |
| Reusable infrastructure patterns shared across teams | CDK construct libraries |
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.