🔗 Original article in Spanish:
“Crea tu propio chat con Claude en AWS Bedrock usando AWS CDK (guía paso a paso para principiantes)”
https://dev.to/chainiz/crea-tu-propio-chat-con-claude-en-aws-bedrock-usando-aws-cdk-guia-paso-a-paso-para-principiantes-20ag
Learn how to build and deploy a serverless AI chat application powered by Claude 3.5 Sonnet (Anthropic) on AWS Bedrock, using AWS CDK (Python) — from scratch.
Perfect for beginners exploring AWS, Infrastructure as Code, and generative AI development in the AWS ecosystem.
🎯 What You Will Build
In this hands-on project you will deploy:
- A Lambda function that invokes Claude 3.5 on AWS Bedrock
- A REST API built with API Gateway (/chat)
- A static web chat interface hosted on S3
- Fully automated provisioning using AWS CDK (Python)
This tutorial gives you a complete end-to-end AI application running in minutes.
✅ Prerequisites
Make sure you have:
- AWS account with Bedrock model access enabled → Bedrock Console → Model Access → anthropic.claude-3-5-sonnet-20240620
- Region: us-east-1
- AWS CDK installed:
npm install -g aws-cdk
- AWS credentials set using aws configure
📦 1. Clone the Project
git clone https://github.com/r3xakead0/aws-cdk-bedrock-claude.git
cd aws-cdk-bedrock-claude
Activate a virtual environment:
uv venv && source .venv/bin/activate
Install dependencies:
uv sync
🧱 2. Architecture Overview
Flow:
- User sends a chat message
- Lambda sends request to Claude (Bedrock Runtime)
- Claude generates a response
- API Gateway returns the answer to the browser
Technologies used:
- AWS Lambda
- Amazon API Gateway
- Amazon S3 (static hosting)
- AWS Bedrock Runtime
- AWS CDK (Python)
💡 3. Key CDK Components
Lambda – calls Claude 3.5 Sonnet
bedrock_rt = boto3.client("bedrock-runtime")
resp = bedrock_rt.invoke_model(
modelId="anthropic.claude-3-5-sonnet-20240620",
body=json.dumps({
"anthropic_version": "bedrock-2023-05-31",
"messages": [{"role": "user", "content": [{"type": "text", "text": prompt}]}],
"max_tokens": 512
})
)
CDK handles IAM, permissions, packaging, and deployment automatically.
🚀 4. Deploy the Full Stack
Bootstrap (first time only):
cdk bootstrap
Deploy:
cdk deploy
You will get:
ApiUrl = https://xxxx.execute-api.us-east-1.amazonaws.com/prod/chat
WebsiteUrl = http://claudechatdemo.s3-website-us-east-1.amazonaws.com
💬 5. How to Test Your Claude Chat App on AWS
Open the website and paste your ApiUrl.
http://claudechatdemo.s3-website-us-east-1.amazonaws.com/
Try this message:
Do you know what a bucket is?
Claude will respond immediately with the generated output.
Yes, I'm familiar with buckets in various contexts. The term "bucket" can have different meanings depending on the context
1. In everyday usage, a bucket is a container used for carrying or storing liquids or other materials
2. In computer science and cloud computing:
- A bucket is a fundamental container for storing data in object storage services like Amazon S3 (Simple Storage Service).
- It's used to organize and control access to data objects
3. In data structures, a bucket is a container that can hold multiple items, often used in hash tables or for sorting algorithms (e.g., bucket sort)
4. In statistics and data analysis, data can be grouped into "buckets" or ranges for easier analysis or visualization
5. In project management, "bucket" might refer to a category or group of related tasks or resources
Given that you're asking about buckets in the context of an AWS expert, I assume you're most likely referring to S3 buckets or similar cloud storage concepts. If you have a more specific question about buckets in a particular context, please feel free to ask.
This is your fully serverless, pay-per-use AI chat app running on AWS ✨
🧪 6. Test Using curl
API="https://xxxx.execute-api.us-east-1.amazonaws.com/prod/chat"
curl -s -X POST "$API" \
-H 'Content-Type: application/json' \
-d '{"prompt":"Summarize AWS Bedrock in 3 bullets"}' | jq
🧹 7. Clean Up
To avoid charges:
cdk destroy
This removes Lambda, API Gateway, and S3.
🧭 What You Learned
- How to deploy AI workloads with AWS Bedrock
- How to build serverless architectures using AWS CDK
- How to host frontend apps on Amazon S3
- How to integrate Claude with your own applications
🌟 Conclusion
This guide shows how easy it is to combine serverless, IaC, and AI to create real, production-ready applications on AWS.
🔗 Source code (open-source): r3xakead0/aws-cdk-bedrock-claude
If this tutorial helped you, leave a ❤️ and tell me which Bedrock model you want to try next!


Top comments (0)