Introducing arn, a library for working with AWS ARNs

At Instacart, we run our infrastructure on AWS, so our systems often deal with AWS ARNs. We often run into cluttered code, and needed to develop a solution for simpler, safer code. That’s why today, we’re releasing arn, a Python library that simplifies parsing, validating, and working with AWS ARNs in a type-safe way. Here’s […]

At Instacart, we run our infrastructure on AWS, so our systems often deal with AWS ARNs. We often run into cluttered code, and needed to develop a solution for simpler, safer code. That’s why today, we’re releasing arn, a Python library that simplifies parsing, validating, and working with AWS ARNs in a type-safe way.

Here’s an example of what arncan do, in this case parsing a Target Group ARN:

https://medium.com/media/e6f6cde4898da28dac0ea4965a3b4c30/href

arn also checks that its input is indeed a valid ARN:

https://medium.com/media/f8101440593dd362cc0537eae2d0870f/href

If you’re using type annotations, arn can help you enforce that function parameters are valid ARNs:

https://medium.com/media/d2f03786c06467ac2e3c8456430a4b34/href

If you have multiple resources in your AWS infrastructure that have some attributes in common, arn can also be used to generate an ARN from another:

https://medium.com/media/5e8f86471b2dc6760335df4b899859c0/href

What resources are supported?

arn is still quite new, so it only supports the AWS resource types that we use here at Instacart, plus a few more popular ones:

ECS

  • Capacity provider
  • Container Instance
  • Cluster
  • Service
  • Task
  • Task definition
  • TaskSet

ELBv2

  • Load Balancers (Application and Network)
  • ALB/NLB Listeners
  • ALB/NLB Listener Rules
  • Target Group

IAM

  • Role
  • STS Assumed role

S3

  • Access point
  • Bucket
  • Job
  • Object

How do I get it?

arn supports Python 3.6 and up and has no runtime dependencies (except for a dataclasses backport if you’re on Python 3.6). To install it, simply run:

pip install arn

or add arn to your setup.pyor requirements.txt.

The docs are available at https://arn.readthedocs.io/en/latest/

I want to contribute

If you’re interested in contributing, or just want to take a look at the source, come visit us at https://github.com/instacart/arn.


Introducing arn, a library for working with AWS ARNs was originally published in tech-at-instacart on Medium, where people are continuing the conversation by highlighting and responding to this story.

Source: Instacart