simple AWS arn parsing and serialization
Project description
simple-arn
A simple AWS ARN parsing and serialization package.
Supports python 3.7+ or 3.6 with the dataclasses backport.
Motivation
Other AWS ARN parsing libraries provide parsing functionality but lack the ability to serialize the parsed ARN back into a string.
Sometimes it is necessary to swap parts of arn strings in the case of resource migration automation and this package provides a simple way to do this:
from simple_arn import AwsArn
arn = AwsArn.parse("arn:aws:iam::123456789012:user/MyUserName")\
.clone(resource="MyOtherUserName")
print(str(arn)) # prints: arn:aws:iam::123456789012:user/MyOtherUserName
Installation
install from PyPI: pip install simple-arn
Usage
This package provides the functionality to parse AWS ARNs into a dataclass AwsArn
and AwsArn
objects can be serialized back into arn strings by simply calling the
object's __str__
method.
AwsArn
objects expose a clone
method allowing for copies of AwsArn
objects
with modified attributes.
Example:
from simple_arn import AwsArn
arn = AwsArn.parse("arn:aws:iam::123456789012:user/MyUserName")
print(str(arn)) # prints: arn:aws:iam::123456789012:user/MyUserName
# clone the arn with a different resource
arn2 = arn.clone(resource="MyOtherUserName")
print(str(arn2)) # prints: arn:aws:iam::123456789012:user/MyOtherUserName
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for simple_arn-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 312da0624906e0d3f8a401ac3fb3aeda1a69101ada8c96ad9ac4deb018a78f2f |
|
MD5 | 71e584d142e8c2fe8d308a28a63075f4 |
|
BLAKE2b-256 | ec2ffa6904cb57e1537d770136362fdd59c8065c31b775a8be857d1161d10a31 |