Skip to main content

Decode AWS Access Key IDs to extract AWS account ID and resource type

Project description

AWS Access Key ID Utility

A Python module for extracting the AWS Account ID and resource type from an AWS Access Key ID. This tool simplifies the process of decoding AWS Access Key IDs to identify account and resource information programmatically.

AWS Resource Type Prefixes

This table lists various prefixes and their associated AWS resource types. For more details, refer to the AWS IAM User Guide - Unique Identifiers.

Prefix Resource Type
ABIA AWS STS service bearer token
ACCA Context-specific credential
AGPA User group
AIDA IAM user
AIPA Amazon EC2 instance profile
AKIA Access key
ANPA Managed policy
ANVA Version in a managed policy
APKA Public key
AROA Role
ASCA Certificate
ASIA Temporary (AWS STS) access key IDs use this prefix, but are unique only in combination with the secret access key and the session token.

Features

  • Extracts the AWS Account ID from an AWS Access Key ID.
  • Identifies the resource type (e.g., IAM user, role, access key).
  • Lightweight and easy to integrate into your projects.

Installation

Install the package via pip:

pip install aws_access_key_id

Usage

Here’s an example of how to use the module in your Python code:

Extracting AWS Account ID and Resource Type

from aws_access_key_id import get_aws_account_id, get_resource_type

# Example AWS Access Key ID
aws_access_key_id = "AKIAEXAMPLE123456"

# Extract account ID
account_id = get_aws_account_id(aws_access_key_id)
print(f"AWS Account ID: {account_id}")

# Identify resource type
resource_type = get_resource_type(aws_access_key_id[:4])
print(f"Resource Type: {resource_type}")

Functions

get_aws_account_id(aws_access_key_id: str) -> str

  • Input: A valid AWS Access Key ID (e.g., "AKIAEXAMPLE123456").
  • Output: The corresponding 12-digit AWS Account ID.

get_resource_type(prefix: str) -> str

  • Input: The 4-character prefix of the AWS Access Key ID.
  • Output: The resource type (e.g., IAM user, Role, Access Key).

Testing

The package includes a test suite to ensure all functionalities work as expected. To run the tests:

  1. Clone the repository:
git clone https://github.com/yourusername/aws-access-key-id.git
cd aws-access-key-id
  1. Install testing dependencies:
pip install pytest
  1. Run the tests:
pytest tests/

Contributing

Contributions are welcome! Follow these steps to contribute:

  1. Fork the repository.
  2. Create a feature branch:
git checkout -b feature-name
  1. Commit your changes:
git commit -m "Add feature or fix description"
  1. Push the branch to your fork:
git push origin feature-name

5 .Open a pull request.

Development Guidelines

  • Code Style: Follow PEP 8 guidelines.
  • Testing: Add test cases for new features in the tests/ directory.
  • Documentation: Update the README.md file for any major changes.

Project Structure

The repository is organized as follows:

aws_access_key_id/
│
├── aws_access_key_id/        # Module folder
│   ├── __init__.py           # Contains your module code
│
├── tests/                    # Test cases folder
│   ├── test_aws_access_key_id.py  # Unit tests for the module
│
├── LICENSE                   # Project license file (e.g., MIT License)
├── README.md                 # Detailed description and usage documentation
├── setup.py                  # Configuration for building and packaging
├── pyproject.toml            # Build system configuration (PEP 517/518)
├── setup.cfg                 # Optional: Additional build configurations

Explanation

aws_access_key_id/: The core module containing all the functionality.

tests/: Contains test cases to ensure the module works as expected.

LICENSE: The license file for the project (e.g., MIT License).

README.md: Documentation about the project, including installation and usage.

setup.py: Configures the module for distribution and packaging.

pyproject.toml: Specifies the build system and dependencies.

setup.cfg: Optional configurations for packaging tools.

License

This project is licensed under the MIT License.

Feedback

If you have any suggestions, issues, or feature requests, feel free to open an issue on the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_access_key_id-1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_access_key_id-1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file aws_access_key_id-1.1.tar.gz.

File metadata

  • Download URL: aws_access_key_id-1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for aws_access_key_id-1.1.tar.gz
Algorithm Hash digest
SHA256 6f7ac2c37bae3e4cc2793cc577bd10d8ad16097b413b4e830b5e053846655283
MD5 c0edfe2ab0897902f0810173432558a9
BLAKE2b-256 4f7ceef4f4602bcb832646101202bc67a0f6b221f71f3cbf95c101d8da083999

See more details on using hashes here.

File details

Details for the file aws_access_key_id-1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_access_key_id-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 022546039bd3d67c202f41bd844cd599a4d061f365d7a9a668e4b38b2954f9ad
MD5 255a048ce2acb218380645c4d5fd5135
BLAKE2b-256 921d13236feb357e5c55bbf2a4bc2ecbef2ec04da7309a728d708c19873443e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page