arnparse
arnparse is a Python library designed to parse Amazon Resource Names (ARNs) into their constituent components like partition, service, region, account ID, and resource. As of version 0.0.2, it provides a straightforward API for extracting information from common ARN formats. The project is in an early stage with a relatively slow release cadence.
Warnings
- gotcha The library is currently at version 0.0.2, indicating an early stage of development. While functional, future major versions may introduce breaking API changes or new behaviors without extensive backward compatibility considerations.
- gotcha While it handles common ARN patterns (e.g., S3, SNS, EC2 VPC), `arnparse` may not comprehensively support all existing and future AWS ARN formats, especially complex or service-specific variations, potentially leading to incomplete or incorrect parsing for certain ARNs.
- gotcha The project's low version number and infrequent updates (last release 0.0.2 in 2019, though GitHub files show a more recent update date of May 2023 for the same version) suggest limited active development and maintenance. This might impact bug fixes, feature requests, or compatibility with newer Python versions or AWS ARN specifications.
Install
-
pip install arnparse
Imports
- arnparse
from arnparse import arnparse
Quickstart
from arnparse import arnparse
# Example: Parsing an SNS Topic ARN
arn_string = 'arn:aws:sns:us-east-1:123456789012:my_corporate_topic'
arn = arnparse(arn_string)
print(f"Original ARN: {arn_string}")
print(f"Partition: {arn.partition}")
print(f"Service: {arn.service}")
print(f"Region: {arn.region}")
print(f"Account ID: {arn.account_id}")
print(f"Resource: {arn.resource}")
# Accessing components directly
assert arn.partition == 'aws'
assert arn.service == 'sns'
assert arn.region == 'us-east-1'
assert arn.account_id == '123456789012'
assert arn.resource == 'my_corporate_topic'