CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-aws-requests-auth

AWS signature version 4 signing process for the python requests module

84

1.10x
Overview
Eval results
Files

task.mdevals/scenario-4/

AWS Request Authenticator

Build a utility that makes authenticated HTTP requests to AWS services with proper payload handling. The utility should handle different types of request bodies and ensure they are correctly signed using AWS Signature Version 4.

Requirements

Your implementation should provide a function that:

  1. Makes authenticated GET and POST requests to AWS Elasticsearch Service endpoints
  2. Properly handles empty request bodies (typical for GET requests)
  3. Correctly processes string request bodies (JSON data as strings)
  4. Correctly processes bytes request bodies (binary data)
  5. Uses AWS credentials to sign requests with proper payload hashing

The function should accept AWS credentials, endpoint information, HTTP method, and optional body data, then return the HTTP response.

Test Cases

  • Making a GET request with no body to an AWS ES endpoint returns a successful response @test
  • Making a POST request with an empty string body to an AWS ES endpoint includes correct content hash @test
  • Making a POST request with JSON string body '{"query": "test"}' includes correct content hash @test
  • Making a POST request with bytes body b'{"data": "binary"}' includes correct content hash @test

Implementation

@generates

API

def make_authenticated_request(method, url, aws_access_key, aws_secret_key,
                               aws_region, aws_service, body=None):
    """
    Makes an authenticated HTTP request to an AWS service.

    Parameters:
    - method (str): HTTP method ('GET' or 'POST')
    - url (str): Full AWS service endpoint URL
    - aws_access_key (str): AWS access key ID
    - aws_secret_key (str): AWS secret access key
    - aws_region (str): AWS region (e.g., 'us-east-1')
    - aws_service (str): AWS service name (e.g., 'es')
    - body (str, bytes, or None): Request body content

    Returns:
    requests.Response: HTTP response object
    """
    pass

Dependencies { .dependencies }

aws-requests-auth { .dependency }

Provides AWS signature version 4 authentication and payload handling capabilities.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-aws-requests-auth

tile.json