AWS Cloud Development Kit

How AWS Cloud Development Kit addresses CloudFormation's shortcomings with reusable code, better testing, and one language for app and configuration.

CLOUDFORMATION LIMITS

Introduction

In short

  • CloudFormation templates are time-consuming to write, hard to document, difficult to reuse, and create merge conflicts.
  • CDK lets you define infrastructure in TypeScript, Python, Java, or C# and generates CloudFormation at build time.
  • CDK allows code reuse through libraries, integrates with your testing suite, and reduces context switching between app code and infrastructure.

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).

CODE-BASED CONFIGURATION

What is CDK?

Cloud Development Kit at its core is a tool that allows you to define infrastructure via your choice of several programming languages. TypeScript, JavaScript, Python, Java, and C# are all officially supported. At build time, a CloudFormation file is generated which can then be used to deploy your cloud resources. This has been extraordinarily beneficial for several teams at JBS as we strive to deliver quality code while maintaining a high velocity.

QUALITY ASSURANCE

Testing

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.

UNIFIED DEVELOPMENT

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.

REUSABILITY

Code Reuse

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 RESULTS

Conclusion

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.

KEEP READING

Related Resources

Contact

Ready to Talk About Your Cloud Platform?

Tell us what you're trying to build, modernize, automate, or fix. We'll help you understand the practical path forward.

Call 888.421.1155