How It's Made
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 an example of what arn
can do, in this case parsing a Target Group ARN:
from arn.elbv2 import TargetGroupArn target_group_arn_str = ( "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/foo-bar/abc123" ) target_group_arn = TargetGroupArn(target_group_arn_str) # use the ARN instance's __str__ to format the ARN back into a string assert str(target_group_arn) == target_group_arn_str # common attributes assert target_group_arn.partition == "aws" assert target_group_arn.service == "elasticloadbalancing" assert target_group_arn.region == "us-east-1" assert target_group_arn.account == "123456789012" # attributes specific to the type of AWS resource assert target_group_arn.name == "foo-bar" assert target_group_arn.internal_id == "abc123"
arn
also checks that its input is indeed a valid ARN:
If you’re using type annotations, arn
can help you enforce that function parameters are valid ARNs:
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:
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.py
or 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.
Most Recent in How It's Made
How It's Made
One Model to Serve Them All: How Instacart deployed a single Deep Learning pCTR model for multiple surfaces with improved operations and performance along the way
Authors: Cheng Jia, Peng Qi, Joseph Haraldson, Adway Dhillon, Qiao Jiang, Sharath Rao Introduction Instacart Ads and Ranking Models At Instacart Ads, our focus lies in delivering the utmost relevance in advertisements to our customers, facilitating novel product discovery and enhancing…...
Dec 19, 2023How It's Made
Monte Carlo, Puppetry and Laughter: The Unexpected Joys of Prompt Engineering
Author: Ben Bader The universe of the current Large Language Models (LLMs) engineering is electrifying, to say the least. The industry has been on fire with change since the launch of ChatGPT in November of…...
Dec 19, 2023How It's Made
Unveiling the Core of Instacart’s Griffin 2.0: A Deep Dive into the Machine Learning Training Platform
Authors: Han Li, Sahil Khanna, Jocelyn De La Rosa, Moping Dou, Sharad Gupta, Chenyang Yu and Rajpal Paryani Background About a year ago, we introduced the first version of Griffin, Instacart’s first ML Platform, detailing its development and support for end-to-end ML in…...
Nov 22, 2023