Donut Shop Part 3
The Problem
AWS (and other cloud providers like Azure, GCP, etc) are powerful toolboxes for building any sort of application. However, with great power comes great responsibility (and complexity). I want to build a backend for my Donut Shop app (ie, a data store and REST API), so will need several components to work together (DynamoDB, Lambda, API Gateway). And while I could create these manually in the AWS console, that would be bush league. A missed opportunity for learning, and building something scalable. Because once this is built, I’m naturally going to want a robust ecosystem with different environments (dev, stage, test, prod), and a fully automated CI pipeline!
Intro to CDK
OK, now that we’ve got the AWS SSO things working correctly, it’s time to crack open the AWS CDK tutorial. This tutorial will walk me through creating a simple app (seems to be just an S3 storage instance), but is a good start for utilizing the CDK. I’ve created a new Github repository (donut-shop) to track the work.
CDK Workshop
After finishing the introductory walkthrough, it’s time for something more involved. AWS has a CDK Workshop that involves a more complete example. After working through the Typescript Workshop, I’ve learned:
- How to create my own construct (a “proxy” lambda function that intercepts API Gateway calls, and records the invocation count of each path in a DynamoDB table)
- How to consume an external construct using NPM.
- Odds and ends (how to troubleshoot issues with a deployed CDK stack, etc)
From here, there are some advanced steps in the CDK workshop, such as testing and pipelines. I’d like to dive into the pipeline portion (so I can deploy stacks in dev/test/prod), but this workshop tutorial seems to use CodeCommit, AWS’s source control repo. I’d rather use Github, so I may have to do some researching next…We’ll see what I find!
Notes and Decisions
Some notes and decisions made along the way:
- Language - Typescript. Javascript is a great choice for a full-stack app, because it runs both in front and back. And Typescript’s use of static types introduces all sorts of benefits (compile-time checks, IDE support, etc). There’s a learning curve with TS, and it complicates the development pipeline a tiny bit, but it’s worth it (and worth learning). More info in the ChatGPT Q/A below.
- cdk init creates a git repository within the folder I’ve created for this CDK app. And within that, a fully functional node app, complete with package.json, tests, etc. I think it’ll take a minute to mentally wrap my head around this - the app within the app, that’s responsible for deploying the app. Cool.
- I finally realized I could default my profile in the cdk.json file with something like this:
"profile": "admin-1",
saves me the time of typing “–profile admin-1” with every cdk execution.
Chat GPT
Here are some highlights of ChatGPT helping accelerate my work.