This is a Python-based CDK (Cloud Development Kit) project that demonstrates how to deploy serverless Lambda functions implementing the Strands Agent framework. The project includes two Lambda functions:
- Weather Forecasting Agent - A simple agent that provides weather forecasting capabilities
- Multi-Modal Processing Agent - An advanced agent that can process and analyze different types of media (images, documents, videos)
- AWS CLI installed and configured
- Python 3.8 or later
- jq (optional) for formatting JSON output
- AWS account with Bedrock access
agent_lambda/- Contains the CDK stack definition in Pythonapp.py- Main CDK application entry pointlayers/- Contains Lambda layers for the Strands Agent frameworkpackage_for_lambda.py- Python script that packages Lambda code and dependencies into deployment archiveslambda_requirements.txt- Dependencies for the Lambda functions
lambdas/code/- Contains the Lambda function codelambda-s-agent/- Weather forecasting agent Lambda functionlambda-s-multimodal/- Multi-modal processing agent Lambda function
- Create a Python virtual environment and install dependencies:
# Create a Python virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install CDK dependencies
pip install -r requirements.txt
# Install Python dependencies for lambda with correct architecture
pip install -r layers/lambda_requirements.txt --python-version 3.12 --platform manylinux2014_aarch64 --target layers/strands/_dependencies --only-binary=:all:- Package the lambda layers:
python layers/package_for_lambda.py- Bootstrap your AWS environment (if not already done):
cdk bootstrap- Deploy the stack:
cdk deployAfter deployment, you can invoke the Lambda functions using the AWS CLI or AWS Console.
aws lambda invoke --function-name AgentSFunction \
--region us-east-2 \
--cli-binary-format raw-in-base64-out \
--payload '{"prompt": "What is the weather in New York?"}' \
output.jsonaws lambda invoke --function-name MultimodalSFunction \
--region us-east-2 \
--cli-binary-format raw-in-base64-out \
--payload '{"prompt": "Analyze this image", "s3object": "s3://your-bucket/path/to/image.jpg"}' \
output.jsonIf you have jq installed, you can output the response from output.json like so:
jq -r '.' ./output.jsonOtherwise, open output.json to view the result.
The Multi-Modal Processing Agent can handle various types of media:
- Images: PNG, JPEG/JPG, GIF, WebP
- Documents: PDF, CSV, DOCX, XLS, XLSX
- Videos: MP4, MOV, AVI, MKV, WebM
The agent uses custom tools built with the Strands Agent framework to process and analyze these media types.
To remove all resources created by this example:
cdk destroy