CDK Subsequent Thoughts

I’ve been using the CDK to build a few workloads, and I’ve really been enjoying it. It isn’t perfect, and there are some weird roadblocks I’ll hit at times, but I’ve gotten a couple of applications in place that I like.

The first is for a simple static site stack. I use the same code for multiple projects, each of which has a configuration file that defines the resources I want and how they will relate to each other.

This app also assumes that the domain is registered outside of AWS, so my configuration file also provides information like MX records, etc, that aren’t AWS related.

What it will build from scratch, though, is a stack with one or more S3 buckets that are linked to a CloudFront distribution, which in turn has an appropriate ACM certificate, and all of the requisite DNS records created to make the file stored in the S3 bucket available as a static website.

The format of the file also lets me vary this a bit with additional buckets, certificates, domains, etc as needed. This isn’t something I always need, but it becomes handy when I want to split up normal content from hosted media.

A related application was built to do all of the above, plus build out Lambda functions and associated API Gateways. Again, these are all defined in a simple YAML file that is processed by some code that is pretty strongly opinionated on what options I can configured. This means that I’m less flexible than I could be, but I also don’t have to guess how something is wired up.

The last bit of special sauce is using a library that syncs the contents of a local directory with S3 buckets, which makes grouping my content and code together in the same repo pretty simple. It does mean that I have to do a CloudFormation change set to publish a change to a single file, but I’m willing to suffer through a couple of extra minutes to have a consistent pipeline.

All of that said, the CDK is still very lacking in documentation and finding sample code can be tricky for edge cases. I imagine this will improve over time, and I plan on continuing to use this for managing all of my personal projects. In fact, as of a few days ago every site I host in my account is now built with the CDK, which is a vast improvement over my manually-built-and-published mess I had combined with some random CF templating.