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-8/

Configuration Management Service

Build a Lambda function that retrieves application configuration from multiple AWS parameter stores and provides a unified configuration object. The service should efficiently retrieve parameters with caching, handle different data types, and support both single and batch retrieval operations.

Requirements

  1. Multiple Parameter Sources: Support retrieving configuration from:

    • AWS Systems Manager (SSM) Parameter Store
    • AWS Secrets Manager
    • DynamoDB table
  2. Single Parameter Retrieval: Implement a function that retrieves a single parameter by name from any of the supported sources.

  3. Batch Parameter Retrieval: Implement a function that retrieves multiple parameters in a single operation. The function should accept a list of parameter names and return a dictionary mapping names to values.

  4. Value Transformation: Support automatic JSON parsing for parameters that contain JSON-formatted strings. The transformation should be applied automatically based on parameter content or naming convention.

  5. Caching: Enable caching for retrieved parameters to reduce API calls. Cache entries should have a reasonable time-to-live (TTL) to balance between freshness and performance.

  6. Error Handling: Handle cases where parameters don't exist gracefully. The system should allow retrieving parameters with a default value if the parameter is not found.

Implementation Details

Create the following functions in config_service.py:

  • get_parameter(name: str, source: str) -> str: Retrieves a single parameter from the specified source
  • get_parameters_batch(names: list, source: str) -> dict: Retrieves multiple parameters from the specified source
  • get_json_parameter(name: str, source: str) -> dict: Retrieves and automatically parses a JSON parameter
  • get_parameter_with_default(name: str, source: str, default: str) -> str: Retrieves a parameter with fallback to default value

The source parameter should accept values: "ssm", "secrets", "dynamodb"

Test Cases

Create test file test_config_service.py:

Test 1: Single Parameter Retrieval { @test }

Input:

  • Parameter name: "/app/database/host"
  • Source: "ssm"

Expected behavior:

  • Function successfully retrieves the parameter value
  • Returns the parameter as a string

Test 2: Batch Parameter Retrieval { @test }

Input:

  • Parameter names: ["/app/api/key1", "/app/api/key2", "/app/api/key3"]
  • Source: "ssm"

Expected behavior:

  • Function retrieves all three parameters in a single operation
  • Returns a dictionary with parameter names as keys

Test 3: JSON Parameter Transformation { @test }

Input:

  • Parameter name: "/app/config.json"
  • Source: "ssm"
  • Parameter contains: {"debug": true, "timeout": 30}

Expected behavior:

  • Function retrieves the parameter and automatically parses it as JSON
  • Returns a Python dictionary object

Test 4: Parameter with Default Value { @test }

Input:

  • Parameter name: "/app/nonexistent"
  • Source: "ssm"
  • Default value: "default_value"

Expected behavior:

  • Parameter does not exist in parameter store
  • Function returns the default value instead of raising an error

Dependencies { .dependencies }

aws-lambda-powertools { .dependency }

Python toolkit for implementing serverless best practices in AWS Lambda.