I Hate having to install stuff on my machine for a project, then have collision on config or versions or when I want to clean things up to free some space. That’s why I always go with dockerized dev environment. But I always struggled setting things up to use the AWS SDK and having the credentials working properly without degrading dev experience. So I finally took some time and built a containerised development template for AWS CDK (TypeScript) projects. The goal is to eliminate local dependency headaches — no need to install Node.js, the AWS CLI, or the CDK on your machine. Everything runs inside Docker via Docker Compose and Make (the only 3 dependencies you must have installed (and bash but I guess you have one if you installed those lol)).
What It Does
This template bundles a complete CDK development environment inside a Docker container using Docker Compose and a Makefile. It includes:
- Node.js: Use your preferred version (prompted during bootstrapping).
- AWS CLI v2: For interacting with AWS.
- AWS CDK CLI: For synthesizing, deploying, and managing infrastructure.
- Package Manager: Choose from pnpm, yarn, or npm.
Note: Although the conditional logic in the Dockerfile supports both x86 and ARM architectures, I have tested this setup mostly on ARM.
Bootstrapping Your Project in a Single Command
Getting started is as simple as cloning the repository and running the bootstrap script (c.f. README of the repository)
git clone git@github.com:PaulSenon/tpl-aws-cdk-dockerized-dev-env.git YOUR_PROJECT_NAME && \
cd YOUR_PROJECT_NAME && \
./bootstrap.sh && \
rm ./bootstrap.sh
The bootstrap process does the following:
- Prompts you to select your Node.js version and package manager. (you can change them latter on in you .env file)
- Initializes the CDK project (cdk init)
- Will prompt you to setup your aws credentials (aws configure) with option between SSO config or access key.
Then you can just start implementing your CDK infrastructure in the created cdk files and deploy it in just 2 commands (because it’s the first time): make cdk-bootstrap
and make cdk-deploy
Then you’ll just have to make cdk-deploy
once more whenever you modified something you want to deploy.
There are a lot more “make” commands to help you interact with this dev environment (read the README.final.md file) from executing an interactive bash in the container to other quick shortcuts to run from host.
And you can always install any tool you need in your dockerized dev env by modifying docker/dev/Dockerfile.devEnv
followed by amake isntall
.
Conclusion
This template provides you with a minimal and consistent Dockerized environment for AWS CDK projects. The bootstrap script sets everything up for you, and the Makefile wraps common operations into simple commands — so you can focus on building your infrastructure, not managing dependencies and configurations.
If you find this helpful or have suggestions for improvements, feel free to contribute or raise an issue on GitHub. This has been setup quickly and not everything has been thoroughly tested yet.
Thanks