AWS Cloud Development Kit (aws-cdk) Consulting

Infrastructure as Code (IaC) tools aren’t new, having appeared on the ThoughtWorks Radar as early as 2011. However, AWS Cloud Development Kit (aws-cdk) represents a significant upgrade to existing tools like CloudFormation, Terraform, Chef, Ansible, etc.

Why AWS CDK?

Instead of directly using a terse configuration language like Hashicorp’s HCL, YAML, or JSON, AWS CDK uses real programming languages like TypeScript, Python, Java, DotNet, and Go. These higher-level languages are then transpiled to the target configuration language, like JSON/YAML or HCL for CloudFormation or Terraform, respectively. Using real programming languages, developers can jump in without learning a new configuration language.

Additionally, AWS CDK provides first-class constructs following best practices. For instance, I can create a VPC, ECS Cluster, and Application Load Balanced ECS Fargate service with eight lines of code!

export class MyEcsConstructStack extends Stack {
  constructor(scope: App, id: string) {
    super(scope, id);

    const vpc = new Vpc(this, "MyVpc");
    const cluster = new Cluster(this, "MyCluster", {
      vpc,
    });

    new ApplicationLoadBalancedFargateService(this, "MyFargateService", {
      cluster,
      taskImageOptions: {
        image: ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
      },
    });
  }
}

This code produces 615 lines of CloudFormation YAML, but, as a developer, I know I’m starting with reasonable defaults from these AWS-supplied constructs (Vpc, Cluster, ApplicationLoadBalancedFargateService). Furthermore, every property exposed via CloudFormation is also configurable via aws-cdk. So, if the defaults don’t suit you, they’re easily changed.

Developer Enablement Teams and AWS CDK

Working with AWS CDK is also a delight for Developer Enablement and DevOps teams. They can write reusable constructs once in TypeScript and create packages for TypeScript, Python, Go, DotNet, and Java without repeating themselves.

So, your enablement team can write a single TypeScript construct, AcmeCorpService, and teams using Node, Python, Go, DotNet and Java can all easily instantiate an AcmeCorpService in their infrastructure as code. This way, all the teams across your organization can leverage the same best practices.

Beyond CloudFormation

AWS CDK supports CloudFormation as its primary transpilation target. However, it’s designed to be completely framework agnostic. For instance, cdktf (CDK for Terraform) allows you to use any Terraform provider without needing to learn or write HCL. Additionally, cdk8s (CDK for Kubernetes) lets you define Kubernetes applications. So, AWS CDK is often a good choice regardless of your preferred infrastructure provisioner!

AWS CDK Consulting

Are you thinking about adopting AWS CDK at your company? Do you have a basic CDK setup you’re looking to improve? I can help 🙂

I have been using aws-cdk since early 2020 and have implemented lots of different solutions for various clients, including:

  • Large monorepos, including shared CDK libraries
  • Construct libraries, including transpiling to all supported CDK languages
  • Continuous Deployment via CDK Pipelines
  • Custom Continuous Deployment via a reusable CircleCI orb

I’m also involved with the CDK project on GitHub. Check out the issues and PRs I’ve worked with. My deep knowledge of the project’s inner workings will ensure you’re using the current best practices in the ecosystem.

Sound interesting? Learn more about my freelance services and get in touch today!