arnparse

0.0.2 · active · verified Sun Apr 12

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

Install

Imports

Quickstart

This example demonstrates how to parse an AWS SNS Topic ARN string and access its individual components using the `arnparse` function.

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'

view raw JSON →