Published on

How to Deploy Bedrock Agents using AWS CDK

Bing Image Creator "A poet sitting on top of a craggy snowcapped peak"

The post this week is a short one because it's mostly just a link to this codebase:


I'd like to take some time here to explain the motivation. Yes, this post is once again about the recipe-creation/presentation using an LLM. On it's own this project isn't extremely useful. However, it is super useful as a foundation from which to build other projects that involve using an LLM to process information, conditionally take an action based on that input information, and the respond appropriately to the user.

With that in mind, the post last week using Bedrock was good for getting up and running, but it was extremely manual. The steps to get up and running with Bedrock involved complicated instructions about "go here, click that, enter this". Wouldn't it be better if it was possible to say "run this command and everything will be ready for you?" Voila, enter AWS CDK?


What is AWS CDK? Basically it's an alternative to Terraform. I've used terraform a lot but as of 5/3/2024, Terraform doesn't yet support bedrock agents, so CDK is one of the few options available for infrastructure as code (IaC) when it comes to bedrock.

AWS CDK can be written in Python and is used to create AWS CloudFormation templates which are then deployed to create the necessary AWS resources. This is appealing because CloudFormation quickly gets complicated and involves using formatting that isn't used anywhere else, so it's hard to debug and read. Writing infrastructure code in python is great because all my existing dev-tools for debugging and development are useful, and now I don't need to learn anything about CloudFormation.

So the long story short is, go here for step by step instructions about how to accomplish all the complicated steps from last weeks post in a few bash commands: https://github.com/njbrake/bedrock-agents-cdk.