šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Book a DemoInstallSign in
Socket

5x-aws-athena-auth-manager

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

5x-aws-athena-auth-manager

A simple Python library for creating an AWS Athena client using access key, secret key and region.

0.1.2
PyPI
Maintainers
1

5X AWS Athena Client Authentication Library

This Python library provides a simple way to create an AWS Athena client using AWS credentials. It handles authentication seamlessly, allowing developers to focus on querying Athena.

  • Authentication Method: AWS Credentials (Access Key and Secret Key)
  • Region Configuration: Configurable AWS Region

Installation

Install the package from PyPI using:

pip install 5x-aws-athena-auth-manager

Environment Variables

This library relies on environment variables for authentication.

VariableDescriptionExample
FIVEX_ATHENA_AWS_ACCESS_KEYAWS Access Key IDAKIA1234567890EXAMPLE
FIVEX_ATHENA_AWS_SECRET_KEYAWS Secret Access KeywJalrXUtnFEMI/K7MDENG/123456
FIVEX_ATHENA_AWS_REGIONAWS Regionus-east-1

Example: Setting Environment Variables

export FIVEX_ATHENA_AWS_ACCESS_KEY="your-access-key"
export FIVEX_ATHENA_AWS_SECRET_KEY="your-secret-key"
export FIVEX_ATHENA_AWS_REGION="your-aws-region"

Usage

Import and Use in Python

from athena_auth import AthenaConnectionManager

try:
    manager = AthenaConnectionManager()
    client = manager.get_client()
    print("āœ… Athena Client Created Successfully!")
except Exception as e:
    print(f"āŒ Error: {e}")

Class Overview

AthenaConnectionManager

Creates and manages an AWS Athena client using environment variables.

How It Works

āœ” Validates AWS credentials from environment variables
āœ” Creates a boto3 Athena client with proper configuration
āœ” Tests the connection to ensure credentials are valid
āœ” Implements comprehensive error handling for debugging

Error Handling

The library provides detailed error handling with specific exceptions:

ExceptionCause
ValueErrorMissing or invalid credentials
ClientErrorAWS API errors (invalid region, etc.)
ConnectionErrorNetwork or connectivity issues
ExceptionUnexpected errors during client creation

Example Error Handling

from athena_auth import AthenaConnectionManager
from botocore.exceptions import ClientError

try:
    manager = AthenaConnectionManager()
    client = manager.get_client()
except ValueError as e:
    print(f"āŒ Configuration Error: {e}")
except ClientError as e:
    print(f"āŒ AWS Client Error: {e}")
except ConnectionError as e:
    print(f"āŒ Connection Error: {e}")
except Exception as e:
    print(f"āŒ Unexpected Error: {e}")

Testing

The library includes comprehensive test utilities:

Simple Test

# simple_test.py
from athena_auth import AthenaConnectionManager

def test_athena_connection():
    manager = AthenaConnectionManager()
    client = manager.get_client()
    response = client.list_work_groups(MaxResults=1)
    print("āœ… Connection successful!")

if __name__ == "__main__":
    test_athena_connection()

Full Test Suite

# Run the complete test suite
python test.py

Dependencies

Core dependencies required:

boto3>=1.26.0
botocore>=1.29.0

Why Use This Library?

āœ” Simplifies AWS Athena authentication – No need to manage credentials manually
āœ” Ensures proper credential validation – Validates credentials before use
āœ” Provides comprehensive error handling – Clear, actionable error messages
āœ” Includes testing utilities – Easy to verify your setup
āœ” Production-ready – Used by 5X platform services

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

License

MIT License - feel free to use this library in your projects!

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts