Building an AI Content Generator: A 7-Hour Debugging Odyssey
I have just completed my AI Content Generator — a tool that utilizes Amazon Bedrock’s Claude model to create on-demand content through a Streamlit frontend. What was supposed to be a quick project turned into a marathon debugging session, teaching me more about AWS, API Gateway, and stubborn error messages than I ever expected.
GitHub Repo: https://github.com/desinthecloud/ai-content-generator
How It Works
The user submits a prompt in the Streamlit app.
The request is routed to an API Gateway endpoint.
A Lambda function processes it and calls the Claude v2.1 model in Bedrock.
The generated content returns to the user like magic!
(Except the magic required 7 hours of troubleshooting.)
The Problems (and Fixes) That Almost Broke Me
1. Claude Wasn’t Even Enabled
Error: Bedrock access denied.
Realization: I’d forgotten to enable Claude in AWS Bedrock.
Fix: I requested access to anthropic.claude-v2:1. In the Bedrock Console, but I only had to wait a few minutes for approval.
2. Model Version Mismatch
Error: Lambda kept failing.
Root Cause: My code referenced anthropic.claude-v2, but the console showed anthropic.claude-v2:1.
Fix: Updated the modelId everywhere and redeployed.
3. Streamlit’s Phantom Variable
Error: NameError: name ‘prompt’ is not defined
Facepalm Moment: I’d mixed up user_input and prompt in the code.
Fix: Standardized variable names across the front end.
4. API Gateway’s Missing /generate Route
Error: 404 Not Found
Mistake: My Streamlit app called /generate. But API Gateway had no such route.
Fix: Simplified the endpoint to /prod and adjusted the front end.
5. API Gateway’s Silent POST Absence
Error: No routes, no methods, just void.
Realization: I’d never configured a POST method in the API Gateway.
Fix: Added a POST method, linked it to Lambda, and enabled CORS.
6. The Mysterious 403 Forbidden
Error: 403 Client Error: Forbidden
Debugging Saga: Triple-checked IAM roles, Lambda permissions, and API Gateway resource policies.
Fix: Granted explicit invocation permissions and redeployed.
7. Streamlit & Pip’s Mac Meltdown
Error: can’t open file pip: [Errno 2] No such file…
Terminal Kung Fu: Fixed it with: Shell -> Copy -> Caption
python3 -m pip install — upgrade pip install — upgrade streamlit
Why I’m Proud of This Project
Terminal-Only Workflow: No AWS Console drag-and-drop — everything was coded, deployed, and debugged via CLI.
Cross-Service Debugging: Learned how Lambda, API Gateway, and Bedrock interact (the hard way).
Error Message Literacy: Now, I read error logs instead of panicking and refreshing.
What’s Next?
Add response streaming for faster outputs.
Deploy the Streamlit app publicly.
Fine-tune Claude for niche content types.
Lesson Learned:
Debugging is like detective work — except you’re also the prime suspect.
Check out the GitHub repo if you want to dive deeper! Feedback and contributions are welcome.