AWS Lambda with Docker

Deploy cryptocom-agent-client as a serverless AWS Lambda function using Docker.

Overview

This example demonstrates how to:

  • Deploy a cryptocom-agent-clientarrow-up-right powered AI agent to AWS Lambda

  • Use Docker containers for Lambda deployment

  • Create custom tools (functions) the agent can invoke

  • Query blockchain data through the Crypto.com Developer Platform

Features

  • AI Agent: Uses OpenAI GPT-4o-mini with cryptocom-agent-clientarrow-up-right

  • Custom Tools:

    • get_current_time() - Returns current local and UTC time

    • fibonacci(n) - Calculates the nth Fibonacci number

  • Blockchain Integration: Query Cronos blockchain data via Developer Platform Dashboard API

  • Serverless: Auto-scaling, pay-per-use AWS Lambda deployment

Prerequisites

Quick Start

1. Configure Environment

Edit .env with your credentials:

2. Deploy to AWS

This will:

  • Build Docker image (ARM64 optimized)

  • Create ECR repository and push image

  • Create IAM role with basic execution permissions

  • Deploy Lambda function (300s timeout, 1024MB memory)

3. Test the Function

4. Clean Up

Local Testing

Test the Lambda function locally before deploying:

Project Structure

Customization

Adding Custom Tools

Edit handler.py to add your own tools:

Register the tool in the agent initialization:

Changing the LLM Model

Modify the llm_config in handler.py:

Using Different Providers

The cryptocom-agent-client supports multiple LLM providers:

Architecture

Lambda Configuration

Setting
Value

Runtime

Python 3.12 (Docker)

Architecture

ARM64

Timeout

300 seconds

Memory

1024 MB

AWS Resource Identifiers

What is ARN?

ARN (Amazon Resource Name) is a unique identifier for any resource in AWS.

Format:

Example for this Lambda:

Resource Identifiers Used

Resource
Identifier

Lambda Function

cryptocom-agent-lambda

ECR Repository

cryptocom-agent-lambda

IAM Role

lambda-exec-cryptocom-agent

Docker Image

cryptocom-agent-lambda:latest

When invoking the Lambda in the same account/region, scripts use just the function name. AWS resolves the full ARN automatically from your credentials.

Security Notes

  • API keys are passed at runtime in the request payload, not stored in Lambda environment

  • The IAM role has minimal permissions (AWSLambdaBasicExecutionRole only)

  • Never commit .env files with real credentials

Troubleshooting

Docker Build Issues

  • Ensure Docker Desktop is running

  • On macOS, the build uses ARM64 for Apple Silicon optimization

Lambda Timeout

  • Default timeout is 300 seconds

  • First invocation may take longer due to cold start

  • Subsequent invocations use cached agent instance

ECR Push Failures

  • Verify AWS credentials are configured: aws sts get-caller-identity

  • Check ECR permissions in your AWS account

License

Apache-2.0

Last updated

Was this helpful?