Looking for ways to speed up deployments with aws-cdk

I have been experimenting with creating an API using almost nothing but typescript and aws-cdk, and so far am loving it. However, running “cdk deploy” is significantly slower than deployments with serverless framework, especially on tiny changes. Changing a variable name inside a handler should be pretty fast, no? Would CDK Pipelines increase deployment speed?

Cdk is wrapper to create cfn template and deploy it. If you feel it’s slower, just generate the template and deploy it using aws-cli.

are you using the cdk deployment pipeline?

my thought is that it shouldn’t matter. as long as it isn’t a large difference.

I’m not using it yet. And with my example of a variable name change, it’s possible to deploy that with serverless framework almost instantly whereas with cdk it will still take a minute.

negligible difference

Isn’t the larger issue that of development cycle? You could leverage the Aws SAM cli to do your quick changes and test local invocations of your lambda. That way you deploy to aws less frequently and speed up your dev cycles.

What services are you deploying?

Also are you sure? CDK tends to wait for all actions to complete or rollback on failure. In my experience its not slower it’s just that other methods don’t wait for the full deployment to finish.

It wouldn’t make a difference to the deployment time. The individual command would complete sooner but the deployment wouldn’t be complete in Cloudformation. Resources would still be being switched, updated and deployed.

No it doesn’t. Serverless framework will push the updates but it won’t wait for aws to finish replacing and warm lambdas with the new versions. CDK waits for the full deployment to complete which is why you’re perceiving longer deploy times.

Not entirely true. Both Serverless Framework and CDK both use CloudFormation under the hood and Serverless Framework does wait for CloudFormation to come back with a “completed” status just like CDK.

In my experience this isn’t the case although I last used the serverless framework a year or so ago so perhaps things have changed. When I used it I could still get lambdas running the wrong version after deploying.

Weird, both serverless and cdk both effectively to the same thing, build cf templates and deploy them.

As it’s using cloudformation under the hood it will always be slow. Biggest con of aws cdk

The Serverless Framework always deploys as LATEST and never switches version. I have never seen this occur over the years so can’t say I can speak from experience with this sort of issue and not heard any of the many people I deal with have this issue either.

i experience the reverse. I find severless deployment 4x slower in comparison to CDK + aws-cli. When running CDK synth you will see the Cfn template and it will be 1:1. For some reason the procedure behind serverless bundles and shooting it to AWS seems longer. The advantage of serverless I find is the yaml definition of your configuration. Much more intuitive. Best recommendation on speedup would be which component can be re-used and deployed. Check the “diff” and also for lambda I would recommend to hook it to s3 bucket and then use aws-cli to change the config instead of letting it done by cdk itself. Open to other discovery

Late to the party here but after a year of working with AWS CDK, I can highly recommend not using it - and going back to Terraform, it’s MUCH faster, more reliable, requires less specialist skills and the ecosystem isn’t a dumpster-fire like with node/npm.