CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-aws-lambda-powertools

Comprehensive developer toolkit implementing serverless best practices for AWS Lambda functions in Python

89

1.21x
Overview
Eval results
Files

task.mdevals/scenario-5/

Order Processing Service

A Lambda function that processes customer orders from an API Gateway endpoint and logs all operations with proper correlation tracking across distributed service calls.

Requirements

Core Functionality

Build a Lambda handler that:

  • Accepts order data from API Gateway events containing order details (order_id, customer_name, items)
  • Logs the start and completion of order processing
  • Simulates calling an external inventory service (log a message indicating the call)
  • Simulates calling an external payment service (log a message indicating the call)
  • Returns a success response with order confirmation

Correlation Tracking

  • Extract and use correlation IDs from incoming requests to track the entire request lifecycle
  • Ensure all log entries include the correlation ID so they can be grouped together
  • The correlation ID should be automatically extracted from API Gateway request headers or context
  • All log messages throughout the handler execution should include this correlation ID

Test Cases

  • Processing an order with correlation ID from request headers produces logs containing that correlation ID @test
  • Processing an order without explicit correlation ID generates logs with an auto-generated correlation ID @test
  • All log entries within a single request share the same correlation ID @test

Implementation

@generates

API

def lambda_handler(event: dict, context) -> dict:
    """
    Process customer orders with correlation ID tracking.

    Args:
        event: API Gateway proxy event containing order details
        context: Lambda context object

    Returns:
        dict: API Gateway proxy response with status code and body
    """
    pass

Dependencies { .dependencies }

aws-lambda-powertools { .dependency }

Provides structured logging with correlation ID management for distributed tracing.

Install with Tessl CLI

npx tessl i tessl/pypi-aws-lambda-powertools

tile.json