AWS CDK: Why your DevOps team should be using it
In Kainos, we live and breathe DevOps.
When we hear the term “DevOps” we can often think solely of Platform Automation or Configuration Management. But in Kainos, DevOps means working collaboratively as a multidisciplinary team through all stages of the software delivery lifecycle. Bringing together platform engineers, developers, UX, testers etc. working towards a single common goal.
The tools we choose to help facilitate this collaboration are incredibly important, as they can have a significant impact to team performance and productivity. For this reason, we constantly review the tools we use to ensure we are staying up to date with the latest and greatest available across the industry.
A tool that very recently attracted my attention is the AWS Cloud Development Kit (CDK), and here are my thoughts on how it might fit into a DevOps model.
What is AWS CDK?
AWS CDK is a development framework which allows you to build cloud applications, including their underlying infrastructure, without leaving your IDE. It offers a high-level object-oriented abstraction for defining AWS resources using modern programming languages which developers are already familiar with (ex. TypeScript, Python, Java, C#, .Net, JavaScript and Go) to provision infrastructure. This familiarity is what empowers developers to become more involved with the infrastructure-as-code concept.
How does it work?
At the core of AWS CDK, there are reusable abstractions called constructs, basic building blocks, that represent AWS resources where CloudFormation acts as a provisioning tool under the hood. You can build your infrastructure by using the AWS Construct Library providing a number of cloud infrastructure code packages that when combined can create the desired functionality or an entire service formed by single or multiple stacks (deployable blocks).
AWS CDK can leverage AWS Solutions Constructs as its open-source library extension that provides a collection of architecture patterns built with the AWS Well-Architected Framework in mind and ensures necessary guardrails.
Why might I choose it over all the other options out there?
As serverless computing has emerged as a very cost-effective solution boosting time-to-market delivery, there is a need for having a proven and consistent way of developing services following that architecture model. Combining that requirement with the ability to use familiar development practices, languages and tools, AWS CDK enables us to increase the overall delivery efficiency. In this aspect, AWS CDK can successfully compete with similar cloud infrastructure orchestrators such as Serverless Framework, which has been available for a much longer period of time.
AWS CDK’s capabilities, however, are not limited to deploying serverless architecture, as this framework can be used in any infrastructure-as-code (IaC) AWS project, from simple proofs-of-concept to more complex production-grade scenarios.
Another essential characteristic of AWS CDK is that it also enables the testing practice to be applied to IaC (e.g. snapshots, assertions, validations). Something that is not always easy to implement when using more traditional infrastructure orchestrators, which can often cause it to be forgotten or simply skipped.
CI/CD pipeline
AWS native tools are our preferred method for deploying and managing the infrastructure we build as they provide maximum integrity, allow us to operate in one ecosystem and reserve our focus for the most important needs – delivering business value.
Therefore, it is nice to see there is also the CDK Pipeline library that makes it easier to set up a CI/CD pipeline for CDK applications using AWS CodePipeline. It consists of several typical stages but can be easily extended by adding additional ones to suit the needs of a given application.
The CDK Pipeline library can sometimes be too opinionated. In which case such a pipeline can also be built with AWS CDK in a custom way by chaining AWS Developer Tools together.
What else should you know?
One thing to keep in mind is that using accelerators like AWS CDK adds another layer of abstraction, which may sometimes lead to loss of control over the infrastructure that it provisions. Here is where DevOps collaboration becomes even more crucial.
It has been only two years since AWS CDK was announced (2019) and everything seems to indicate that it has already become a game-changer seeing its potential is being brought to another level by Hashicorp and Cloud Native Computing Foundation for the benefit of the wider DevOps community.
Hashicorp pushed out a beta of CDKtf – the AWS CDK for Terraform, used as the cloud infrastructure provisioning tool, while CNCF released CDK8s as a sandbox project that allows defining Kubernetes applications and reusable abstractions by synthesising apps into standard manifests that then can be applied to any Kubernetes cluster.
Regardless of if you want to use AWS CDK natively or any of its implementations, what you can create with them is only limited by the engines sitting underneath.
Conclusion
AWS CDK is a great option for any AWS everything-as-code project by making infrastructure code development even more developer-friendly. Bringing that common ground to both applications and infrastructure is what makes it be considered a collaborative tool within the DevOps area as it unifies the codebase for both developers and platform engineers.
Moreover, AWS CDK is all about creating customisable and reusable modules that can empower DevOps teams while ensuring a consistent level of security and compliance. That should also translate into overall project bootstrapping and development efficiency.