Parse AWS ARNs into structured data (2000+ resource types)
Project description
arnmatch
Parse AWS ARNs into structured data.
Overview
Working with AWS at scale raises questions that are surprisingly hard to answer:
- What resource does this ARN represent? - ARN formats vary across services with no consistent parsing rules
- What ARN formats exist? - No single source documents all valid ARN patterns
- What resource types exist on AWS? - Scattered across 300+ service documentation pages
- What CloudFormation/Tagging API type maps to this ARN? - No direct ARN-to-CFN or ARN-to-Tagging mapping exists
arnmatch answers these questions by:
- Parsing ARNs into structured components (service, region, account, resource type, resource ID)
- Providing a complete index of 2000+ resource types from 300+ AWS services
- Mapping ARNs to CloudFormation resource types (e.g.,
arn:aws:lambda:...:function:X→AWS::Lambda::Function) - Mapping ARNs to Resource Groups Tagging API types for tag operations
Patterns are auto-generated from AWS Service Authorization Reference.
Features
- Zero runtime dependencies
- 300+ AWS services, 2000+ resource types
- Patterns auto-generated from AWS official documentation
- CLI and library interface
- CloudFormation resource type mapping
- Resource Groups Tagging API type mapping
- Boto3 SDK service name mapping
Installation
pip install arnmatch
Quick Start
CLI
$ arnmatch "arn:aws:lambda:us-east-1:123456789012:function:my-function"
aws_service: lambda
aws_sdk_service: lambda
aws_sdk_services: lambda
aws_region: us-east-1
aws_account: 123456789012
resource_type: function
resource_id: my-function
resource_name: my-function
cloudformation_resource: AWS::Lambda::Function
tagging_resource: AWS::Lambda::Function
Library
from arnmatch import arnmatch
result = arnmatch("arn:aws:lambda:us-east-1:123456789012:function:my-function")
result.aws_service # "lambda"
result.aws_region # "us-east-1"
result.aws_account # "123456789012"
result.resource_type # "function"
result.resource_id # "my-function"
result.resource_name # "my-function"
result.cloudformation_resource # "AWS::Lambda::Function"
result.tagging_resource # "AWS::Lambda::Function"
result.aws_sdk_service # "lambda"
# Get a boto3 client for the service
client = result.client()
client.get_function(FunctionName=result.resource_name)
API Reference
arnmatch(arn: str) -> ARN
Parse an ARN string and return structured data.
Raises ARNError if the ARN format is invalid or no pattern matches.
ARN
Dataclass with parsed ARN components:
| Field | Type | Description |
|---|---|---|
aws_partition |
str |
AWS partition (aws, aws-cn, aws-us-gov) |
aws_service |
str |
AWS service name |
aws_region |
str |
AWS region (may be empty for global resources) |
aws_account |
str |
AWS account ID |
resource_type |
str |
Canonical resource type from AWS docs |
resource_types |
list[str] |
All known names for this resource type |
attributes |
dict[str, str] |
All captured attributes from the ARN |
aws_sdk_service |
str | None |
Primary boto3 client name |
cloudformation_resource |
str | None |
CloudFormation resource type |
tagging_resource |
str | None |
Resource Groups Tagging API type |
Properties:
| Property | Description |
|---|---|
resource_id |
Resource identifier (prefers attributes ending in Id, then Name, then last attribute) |
resource_name |
Resource name (prefers attributes ending in Name, falls back to resource_id) |
aws_sdk_services |
List of boto3 client names (e.g., ['elb', 'elbv2'] for elasticloadbalancing) |
Methods:
| Method | Description |
|---|---|
client(session=None) |
Returns a boto3 client for the resource's service. Pass an optional boto3.Session or uses default. Raises ValueError if no SDK mapping exists. |
ARNError
Exception raised when ARN parsing fails. Inherits from ValueError.
Development
Prerequisites: uv
make lint # Run ruff linter
make test # Run pytest tests
make check # Run lint and test
make generate # Regenerate patterns from AWS docs
make build # Build wheel and tarball
make publish # Build and upload to PyPI
Versioning
CalVer format YYYY.MM.MICRO (e.g., 2026.2.0).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arnmatch-2026.3.1.tar.gz.
File metadata
- Download URL: arnmatch-2026.3.1.tar.gz
- Upload date:
- Size: 895.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7e08fddd4a22caa9e1f3a3c3a267d0ef1e181c4cc3365e99e636b4395963eff
|
|
| MD5 |
1afc6938a2a46c63c956f964af1f33a5
|
|
| BLAKE2b-256 |
eab7b0afc4682454f9112102e2af43e8fea17d747705a2d6506c3a2fe65f9cf7
|
Provenance
The following attestation bundles were made for arnmatch-2026.3.1.tar.gz:
Publisher:
workflow.yml on andreygubarev/arnmatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arnmatch-2026.3.1.tar.gz -
Subject digest:
f7e08fddd4a22caa9e1f3a3c3a267d0ef1e181c4cc3365e99e636b4395963eff - Sigstore transparency entry: 1172110685
- Sigstore integration time:
-
Permalink:
andreygubarev/arnmatch@9e21d5fb8615426499bde4aa58b3eba2c8d0a054 -
Branch / Tag:
refs/tags/2026.3.1 - Owner: https://github.com/andreygubarev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@9e21d5fb8615426499bde4aa58b3eba2c8d0a054 -
Trigger Event:
push
-
Statement type:
File details
Details for the file arnmatch-2026.3.1-py3-none-any.whl.
File metadata
- Download URL: arnmatch-2026.3.1-py3-none-any.whl
- Upload date:
- Size: 68.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f07f0419b72eac8219a96854bc40367e18246404a0471b01105f2cccd69bf82
|
|
| MD5 |
f83c71b0c0c2a8b5c14390a4197757c9
|
|
| BLAKE2b-256 |
0f6dbe5a7ef5d42cfe7f05f34f9f511e7694441b32d88ecb14175f422a3bc812
|
Provenance
The following attestation bundles were made for arnmatch-2026.3.1-py3-none-any.whl:
Publisher:
workflow.yml on andreygubarev/arnmatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arnmatch-2026.3.1-py3-none-any.whl -
Subject digest:
4f07f0419b72eac8219a96854bc40367e18246404a0471b01105f2cccd69bf82 - Sigstore transparency entry: 1172110704
- Sigstore integration time:
-
Permalink:
andreygubarev/arnmatch@9e21d5fb8615426499bde4aa58b3eba2c8d0a054 -
Branch / Tag:
refs/tags/2026.3.1 - Owner: https://github.com/andreygubarev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@9e21d5fb8615426499bde4aa58b3eba2c8d0a054 -
Trigger Event:
push
-
Statement type: