How do you implement microservices with serverless?

Answer

Serverless microservices organize functions around bounded contexts or business capabilities. Architecture patterns: (1) Function-per-endpoint — each HTTP endpoint maps to a dedicated Lambda function (GET /users/{id}getUserHandler); (2) Function-per-service — one Lambda handles all operations for a domain (users service Lambda handles GET, POST, PUT, DELETE users using a routing library like serverless-http + Express); (3) Event-driven microservices — services communicate via SQS, SNS, or EventBridge events rather than synchronous API calls, creating loose coupling; (4) Service boundaries — each microservice deploys its own infrastructure (separate Serverless Framework service or CDK stack) with its own DynamoDB table, IAM roles, and API resources. Challenges: distributed tracing across functions (AWS X-Ray), local development (LocalStack, SAM Local), inter-service authentication (Lambda-to-Lambda via IAM), and managing the "nanoservices" anti-pattern (functions too granular to be meaningful).