arnparse
Parse ARNs using Python
Motivation
Sometimes, you want to parse an Amazon Resource Name (ARN) into its components to get some useful information from the ARN (e.g. AWS region, account ID, etc).
You can find documentation on ARNs and their components here: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
Installation
pip install arnparse
Examples
S3 Object
from arnparse import arnparse
arn = arnparse('arn:aws:s3:::my_corporate_bucket/exampleobject.png')
assert arn.partition == 'aws'
assert arn.service == 's3'
assert arn.region is None
assert arn.account_id is None
assert arn.resource_type is None
assert arn.resource == 'my_corporate_bucket/exampleobject.png'
VPC
from arnparse import arnparse
arn = arnparse('arn:aws:ec2:us-east-1:123456789012:vpc/vpc-fd580e98')
assert arn.partition == 'aws'
assert arn.service == 'ec2'
assert arn.region == 'us-east-1'
assert arn.account_id == '123456789012'
assert arn.resource_type == 'vpc'
assert arn.resource == 'vpc-fd580e98'
CloudWatch Alarm
from arnparse import arnparse
arn = arnparse('arn:aws:cloudwatch:us-east-1:123456789012:alarm:MyAlarmName')
assert arn.partition == 'aws'
assert arn.service == 'cloudwatch'
assert arn.region == 'us-east-1'
assert arn.account_id == '123456789012'
assert arn.resource_type == 'alarm'
assert arn.resource == 'MyAlarmName'
SNS Topic
from arnparse import arnparse
arn = arnparse('arn:aws:sns:*:123456789012:my_corporate_topic')
assert arn.partition == 'aws'
assert arn.service == 'sns'
assert arn.region == '*'
assert arn.account_id == '123456789012'
assert arn.resource_type is None
assert arn.resource == 'my_corporate_topic'
API Gateway
from arnparse import arnparse
arn = arnparse('arn:aws:apigateway:us-east-1::a123456789012bc3de45678901f23a45:/test/mydemoresource/*')
assert arn.partition == 'aws'
assert arn.service == 'apigateway'
assert arn.region == 'us-east-1'
assert arn.account_id is None
assert arn.resource_type is None
assert arn.resource == 'a123456789012bc3de45678901f23a45:/test/mydemoresource/*'
Metadata
Release files for arnparse 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arnparse-0.0.2.tar.gz | 2.7 kB | Without provenance | Details for arnparse-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arnparse-0.0.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for arnparse-0.0.2-py2.py3-none-any.whl |
Total release size: 5.6 kB
Release files / arnparse-0.0.2.tar.gz
| Download URL | arnparse-0.0.2.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb87f17200d07121108a9085d4a09cc69a55582647776b9a917b0b1f279db8f8
|
|
BLAKE2b-256 checksum How to use checksums |
bd42949284e998282b167e273872fa9c39b06d41a6055163c30aa2daaeee76a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.3
|
Release files / arnparse-0.0.2-py2.py3-none-any.whl
| Download URL | arnparse-0.0.2-py2.py3-none-any.whl |
|---|---|
| Size | 2.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b0906734e4b8f19e39b1e32944c6cd6274b6da90c066a83882ac7a11d27553e0
|
|
BLAKE2b-256 checksum How to use checksums |
576f630bedeb32964e99661990811a66389201b62c047b35c17e332dad9be2a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.3
|
Security for arnparse 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.