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+ PyPI

Overview

Working with AWS at scale raises questions that are surprisingly hard to answer:

  1. What resource does this ARN represent? - ARN formats vary across services with no consistent parsing rules
  2. What ARN formats exist? - No single source documents all valid ARN patterns
  3. What resource types exist on AWS? - Scattered across 300+ service documentation pages
  4. What CloudFormation type maps to this ARN? - No direct ARN-to-CFN 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:XAWS::Lambda::Function)

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
  • 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

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.aws_sdk_service        # "lambda"

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

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)

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


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.2.1.tar.gz (850.4 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.2.1-py3-none-any.whl (62.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for arnmatch-2026.2.1.tar.gz
Algorithm Hash digest
SHA256 f9d459e7af50d5abb55c0cdcb67490d0332d527ae41ad8c4f0f0a4443cb6ce07
MD5 b8ef74fe53ce7703ebe976f920601ece
BLAKE2b-256 5a1c12f9a4242bf6f85788e4809ad2d66d2ff1f32b78817d5d2f25ee6f6f3ecc

See more details on using hashes here.

Provenance

The following attestation bundles were made for arnmatch-2026.2.1.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.2.1-py3-none-any.whl.

File metadata

  • Download URL: arnmatch-2026.2.1-py3-none-any.whl
  • Upload date:
  • Size: 62.4 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5ba379d7c2c22e9c0f571ba8d5dc0400d7fc951c3fdb0405d8f366db0d5b2a1
MD5 8655d353187286fcc1c202940f197616
BLAKE2b-256 59d0cf3d97f53ffa713c36a0f85a5e23e9c3aa15f0c384f02d5798ba60d5e776

See more details on using hashes here.

Provenance

The following attestation bundles were made for arnmatch-2026.2.1-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