or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/aws-lambda-powertools@3.19.x
tile.json

tessl/pypi-aws-lambda-powertools

tessl install tessl/pypi-aws-lambda-powertools@3.19.0

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

Agent Success

Agent success rate when using this tile

89%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.22x

Baseline

Agent success rate without this tile

73%

task.mdevals/scenario-9/

User Profile Service

Build a simple user profile management service that exposes HTTP endpoints via AWS Lambda Function URLs.

Requirements

Implement a Lambda function that handles HTTP requests for managing user profiles. The service should:

  1. GET /users/<user_id> - Retrieve a user profile by ID

    • Return 200 with user data if found
    • Return 404 if user doesn't exist
    • User data should include: id, name, email
  2. POST /users - Create a new user profile

    • Accept JSON body with name and email fields
    • Return 201 with created user data
    • Return 400 if required fields are missing
  3. PUT /users/<user_id> - Update an existing user profile

    • Accept JSON body with optional name and/or email fields
    • Return 200 with updated user data
    • Return 404 if user doesn't exist
  4. CORS Support - Enable CORS for all endpoints

    • Allow origin: "*"
    • Allow methods: GET, POST, PUT
    • Allow headers: Content-Type
  5. Error Handling - Handle validation errors gracefully

    • Return 400 status code with error message for validation failures

Implementation Notes

  • Store user data in memory (no database required)
  • Use simple string IDs for users (e.g., "1", "2", "3")
  • JSON responses should be automatically serialized
  • Pre-populate with 2 sample users for testing

Test Cases

  • Retrieving an existing user returns 200 with correct user data @test
  • Retrieving a non-existent user returns 404 @test
  • Creating a user with valid data returns 201 @test
  • Creating a user without required fields returns 400 @test
  • Updating an existing user returns 200 with updated data @test
  • Updating a non-existent user returns 404 @test

Implementation

@generates

API

def lambda_handler(event: dict, context) -> dict:
    """
    Lambda handler for processing Function URL requests.

    Parameters:
    - event: Lambda Function URL event
    - context: Lambda runtime context

    Returns:
    Lambda Function URL response dictionary
    """

Dependencies { .dependencies }

aws-lambda-powertools { .dependency }

Provides event handler support for Lambda Function URLs.