portrait

End of Line blog

Thoughts on software development, by Adam Ruka

CDK tips, part 4 – how to migrate from CloudFormation to CDK

This article is part of a series on working with the Cloud Development Kit:


The CDK allows you to express your infrastructure using high-level, object-oriented code in familiar programming languages like JavaScript/TypeScript, Python and Java. When that code gets executed, it produces one or more CloudFormation templates as a result. When invoking a command like cdk deploy, it’s the CloudFormation service that performs the actual provisioning of the AWS resources defined by the CDK code.

Given that, a natural question a lot of CDK users ask is how to go in the opposite direction: migrate an existing CloudFormation Stack to be managed through the CDK. Many AWS customers have significant investment in CloudFormation already, and they don’t want to start from scratch when moving to (or just trying out) the CDK.

The CDK has a dedicated module to help with this migration, called CloudFormation-Include. There is an article on the AWS blog that shows how to use it: https://aws.amazon.com/blogs/developer/migrating-cloudformation-templates-to-the-aws-cloud-development-kit.

I also recently gave a talk at a Berlin AWS User Group meetup, during which I showed a live demo of moving a CloudFormation Stack deployed through the Serverless Application Repository to the CDK. Unfortunately, that presentation was not recorded. I liked how the demo went so much, however, that I decided to make a video going through it again:

I hope it’s helpful in demonstrating how to migrate a real-life, running application from CloudFormation to CDK, without any downtime, or incurring additional charges for new resources.

Let me know what you think of the video!


This article is part of a series on working with the Cloud Development Kit: