If your team is using CloudFormation as its Infrastructure as a Code solution but is challenged by its many shortcomings, there may be a better option. CloudFormation is powerful, but as our team scaled, it presented us with several issues.
Adding resources via CloudFormation templates can be a time-intensive and frustrating process. The documentation leaves a lot to be desired and the lack of reusability leads to a lot of repetitive configuration. We frequently struggled with merge conflicts that were made difficult to resolve by the confusing structure of CloudFormation resource definitions.
A common complaint from our team was that we would spend as much time configuring the resources as we would write the code for a new API endpoint. On top of that, there was not a solid solution when it came to testing our configuration. This led us to search for an alternative and we landed on Amazon’s Cloud Development Kit (CDK).
What is CDK?
Right out of the gate, we benefitted from being able to define our resources in Typescript. We set up our automated testing suite to run our application and CDK stack tests via a single command. This allowed us to seamlessly transition from writing unit tests for our app code to write them also for our configuration. We also enabled our main application’s linter to cover our CDK configuration which keeps our coding style consistent and clean.
One Programming Language for App and Configuration
Before using CDK, adding cloud resources felt like a chore which was a separate effort from developing the functionality which would utilize those resources. Once we integrated CDK, that changed overnight. The process of adding resources and developing a feature now went hand in hand. The reduced context switching produced a clear uptick in velocity for our team.
From a technical perspective, one of the greatest benefits of using CDK is the ability to reuse code. As a part of our migration effort, we stood up a standalone library with standardized definitions for our most frequently used resources. This meant that if you wanted to add an S3 bucket, all the boilerplate was gone and you simply had to instantiate a bucket with the desired name and encryption key. It allowed our team to focus on the functionality we needed to deliver instead of having to worry about how to properly define a CloudFormation resource.
The transition to CDK has been a tremendous success. Replacing tedious CloudFormation template development with streamlined code helped us to eliminate a major source of pain. It allowed us to deploy cloud resource changes more efficiently and do so while increasing quality via our testing suite.