Skip to main content

Parse AWS ARNs into structured data (2000+ resource types)

Project description

arnmatch

Parse AWS ARNs into structured data.

Python 3.10+

Why

AWS ARN formats are inconsistent. This problem was unsolved. Now it's solved (for 2000+ resource types from 300+ services). You're welcome.

Features

  • Zero runtime dependencies
  • 300+ AWS services, 2000+ resource types supported
  • Patterns auto-generated from AWS official documentation
  • CLI and library interface
  • Extracts resource type, ID, and name with smart heuristics

Installation

pip install arnmatch

Quick Start

CLI

$ uvx arnmatch "arn:aws:lambda:us-east-1:123456789012:function:my-function"
aws_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

Library

from arnmatch import arnmatch

arn = "arn:aws:lambda:us-east-1:123456789012:function:my-function"
result = arnmatch(arn)

print(result.aws_service)      # lambda
print(result.aws_sdk_services) # ['lambda']
print(result.aws_region)       # us-east-1
print(result.aws_account)      # 123456789012
print(result.resource_type)    # function
print(result.resource_id)      # my-function
print(result.resource_name)    # my-function
print(result.attributes)       # {'Partition': 'aws', 'Region': 'us-east-1', ...}

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 pattern

Properties:

Property Description
resource_id Resource identifier (prefers groups ending in Id, falls back to Name, then last group)
resource_name Resource name (prefers groups ending in Name, falls back to resource_id)
aws_sdk_services List of boto3 client names for this service (e.g., ['elb', 'elbv2'] for elasticloadbalancing)

ARNError

Exception raised when ARN parsing fails. Inherits from ValueError.

Versioning

This project uses CalVer with format YYYY.0M.MICRO (e.g., 2026.01.0).

Development

Prerequisites: uv

make lint       # Run ruff linter
make test       # Run pytest tests
make check      # Run lint and test
make build      # Build wheel and tarball
make publish    # Build and upload to PyPI
make clean      # Remove build artifacts

Regenerate patterns from AWS docs:

cd codegen && uv run codegen.py

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

arnmatch-2026.1.2.tar.gz (66.6 kB view details)

Uploaded Source

Built Distribution

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

arnmatch-2026.1.2-py3-none-any.whl (44.3 kB view details)

Uploaded Python 3

File details

Details for the file arnmatch-2026.1.2.tar.gz.

File metadata

  • Download URL: arnmatch-2026.1.2.tar.gz
  • Upload date:
  • Size: 66.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for arnmatch-2026.1.2.tar.gz
Algorithm Hash digest
SHA256 581fd37345fd131743e44d2602e88914ca2b39ecb08e71f6e90a573b4d7477e3
MD5 2eb5043827a9c0e6685716141d51aa31
BLAKE2b-256 4baf3c94ea4d93e4d6b54d6f3e422272d5748a95165e16b31d7d0165192975c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for arnmatch-2026.1.2.tar.gz:

Publisher: workflow.yml on andreygubarev/arnmatch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file arnmatch-2026.1.2-py3-none-any.whl.

File metadata

  • Download URL: arnmatch-2026.1.2-py3-none-any.whl
  • Upload date:
  • Size: 44.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for arnmatch-2026.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 72c39efe2d97ff33e427fd21db168ab915c8cba89f120e220fc5013ccc43ef5b
MD5 c81dec2f0faddacce724ec9537b7e35b
BLAKE2b-256 e5760e9dfc174d059f7760de8d9802e48a539404f1c86ac01e2f3d7ee8a8f8c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for arnmatch-2026.1.2-py3-none-any.whl:

Publisher: workflow.yml on andreygubarev/arnmatch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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