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:
- Clone the repository:
git clone https://github.com/yourusername/aws-access-key-id.git
cd aws-access-key-id
- Install testing dependencies:
pip install pytest
- Run the tests:
pytest tests/
Contributing
Contributions are welcome! Follow these steps to contribute:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add feature or fix description"
- 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.
Metadata
Release files for aws-access-key-id 1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aws_access_key_id-1.3.tar.gz | 5.4 kB | Without provenance | Details for aws_access_key_id-1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aws_access_key_id-1.3-py3-none-any.whl | Python 3 | none | any | Details for aws_access_key_id-1.3-py3-none-any.whl |
Total release size: 10.9 kB
Release files / aws_access_key_id-1.3.tar.gz
| Download URL | aws_access_key_id-1.3.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e6adba44884dc09433ec27e88abd199a3dc1891d93dc74f479071355cd5f19f3
|
|
BLAKE2b-256 checksum How to use checksums |
8f9614507101b756c1344d2ec47be7cb023224a24e00e4199b0c94ef23b8ed95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / aws_access_key_id-1.3-py3-none-any.whl
| Download URL | aws_access_key_id-1.3-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19092b919d125c0d6522d5cad06ed1a0ebf7c26c0216518fc55e7ca38439a9c3
|
|
BLAKE2b-256 checksum How to use checksums |
cc643266c37d48eda030ee0231a376d79e1521abb3240673fa3a7439ee99d925
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for aws-access-key-id 1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.