- Newest
- Most votes
- Most comments
Hey! I've built a CDK construct specifically to solve this problem - https://constructs.dev/packages/token-injectable-docker-builder.
This construct builds the image in CodeBuild at deployment time, rather than locally at build time.
Cheers!
Hi Smotrov,
Typically CDK is meant for infrastructure as code, so building the image per se is not part of that.
What you can do is to provision native cloud pipelines in cdk, that allow you to build the images.
An example is code pipeline and code build where you can build a docker image: https://github.com/aws-samples/aws-cdk-examples/blob/master/python/codepipeline-docker-build/ReadMe.md
So if you wish to execute the building of the image with cdk, I d create a script that executes both cdk deploy and that triggers a code pipeline starts.
Hope it helps and fits your case
Relevant content
- asked 8 months ago
- asked 3 years ago

Wow! Alex, it looks like a perfect solution! Amazing! Thank you.
However big build is failing with (signal: 9, SIGKILL: kill). Investigating, not sure if it is related to your library.
Hmm interesting. Something to note about the library is that it builds the Docker containers for Linux OS, meaning it will not work (for example) if you have an ECS cluster running on a fleet of Mac or Windows EC2's. The reason for this choice is to support running container image lambda functions easily. Also, your error, (signal: 9, SIGKILL: kill), is a runtime error, not a build-time error. But feel free to post an issue on the GitHub if you'd like me to take a look! https://github.com/AlexTech314/TokenInjectableDockerBuilder/issues - Just try to make it as descriptive as possible :)