Ctrl + K
DocumentationLog inGet started

tessl/pypi-aws-requests-auth

tessl install tessl/pypi-aws-requests-auth@0.4.0

AWS signature version 4 signing process for the python requests module

Agent Success

Agent success rate when using this tile

84%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.11x

Baseline

Agent success rate without this tile

76%

task.mdevals/scenario-6/

AWS Multi-Service HTTP Client

Build a Python HTTP client utility that can make authenticated requests to multiple AWS services using AWS Signature Version 4 authentication.

Requirements

Your client should support making authenticated HTTP requests to two different AWS services:

  1. AWS Elasticsearch Service: Support GET requests to query Elasticsearch endpoints
  2. AWS API Gateway: Support POST requests with JSON payloads to API Gateway endpoints with IAM authentication

The client should:

  • Accept AWS credentials (access key ID and secret access key) as initialization parameters
  • Allow specifying the AWS region for each request
  • Properly configure authentication for the specific target service (Elasticsearch uses service name es, API Gateway uses execute-api)
  • Handle empty payloads for GET requests and JSON payloads for POST requests
  • Return the HTTP response for each request

Test Cases

Test Case 1: Elasticsearch Query { @test }

  • Given valid AWS credentials and an Elasticsearch endpoint in us-east-1
  • When making a GET request to search an index
  • Then the request should include proper AWS Signature Version 4 authentication headers
  • And the Authorization header should contain the correct signature for the Elasticsearch service

@test

Test Case 2: API Gateway Request { @test }

  • Given valid AWS credentials and an API Gateway endpoint in eu-west-1
  • When making a POST request with a JSON payload {"message": "hello"}
  • Then the request should include proper authentication headers for the execute-api service
  • And the request should include the correct payload hash in the headers

@test

Implementation

@generates

API

class AWSMultiServiceClient:
    """
    A client for making authenticated requests to multiple AWS services.
    """

    def __init__(self, aws_access_key_id: str, aws_secret_access_key: str):
        """
        Initialize the client with AWS credentials.

        Args:
            aws_access_key_id: AWS access key ID
            aws_secret_access_key: AWS secret access key
        """
        pass

    def query_elasticsearch(self, host: str, region: str, path: str) -> dict:
        """
        Make a GET request to an AWS Elasticsearch endpoint.

        Args:
            host: The Elasticsearch endpoint (e.g., 'search-domain.us-east-1.es.amazonaws.com')
            region: AWS region (e.g., 'us-east-1')
            path: The request path (e.g., '/index/_search')

        Returns:
            Response as a dictionary
        """
        pass

    def invoke_api_gateway(self, host: str, region: str, path: str, payload: dict) -> dict:
        """
        Make a POST request to an AWS API Gateway endpoint.

        Args:
            host: The API Gateway endpoint (e.g., 'api123.execute-api.us-east-1.amazonaws.com')
            region: AWS region (e.g., 'us-east-1')
            path: The request path (e.g., '/prod/resource')
            payload: JSON payload as a dictionary

        Returns:
            Response as a dictionary
        """
        pass

Dependencies { .dependencies }

aws-requests-auth { .dependency }

Provides AWS Signature Version 4 authentication for HTTP requests.

requests { .dependency }

HTTP library for making requests to AWS services.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/aws-requests-auth@0.4.x
tile.json