arn package¶
-
exception
arn.
InvalidArnException
(arn: str)¶ Bases:
Exception
Raised when the value cannot be parsed as a valid ARN.
-
exception
arn.
InvalidArnRestException
(rest: str, class_name: str)¶ Bases:
Exception
Raised when the value can be parsed as a valid ARN but the rest cannot.
-
exception
arn.
ConflictingFieldNamesException
(field_names: Set[str])¶ Bases:
Exception
A subclass tried to use reserved field names.
The
partition
,service
,region
, andaccount
names are reserved and cannot be used as attributes.
-
class
arn.
Arn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '')¶ Bases:
object
The base class that represents an AWS ARN.
This class is meant to be used as a superclass for more specific ARN classes. Instantiating this class with a valid ARN will parse out the common fields (
partition
,service
,region
, andaccount
), and will place the rest of the ARN string in therest
field.-
REST_PATTERN
: ClassVar[Union[str, Pattern]] = re.compile('(?P<rest>.*)')¶ The pattern that parses the “rest” of the ARN. The “rest” of and ARN is the part that is specific to the AWS service that the ARN represents. When overriding in a subclass, this value can be either an re.Pattern or an
str
.
-
input_arn
: Any¶ The instance that was parsed, unchanged.
-
partition
: str = ''¶ The partition of the AWS of the resource.
-
service
: str = ''¶ The AWS service of the resource.
-
region
: str = ''¶ The AWS region in which the resource is located.
-
account
: str = ''¶ The AWS account ID of the resource.
-
rest
: str = ''¶ The rest of the ARN, as matched by
REST_PATTERN
.
-
match_rest
(rest: str) → Optional[Match]¶ Convert the rest of the ARN into an re.Match.
By default, matches the rest of the ARN against
REST_PATTERN
. Override this metod to match against a pattern dynamically. For an example, seearn.ecs.ServiceArn.match_rest()
.
-
assign_rest
(match: Match)¶ Assign an re.Match’s groups to fields on
self
.By default, assigns all named groups in
REST_PATTERN
as strings. Override this method to cast group matches to a more appropriate type. For an example, seearn.ecs.TaskDefinitionArn.assign_rest()
.
-
format_rest
() → str¶ Produce a formatted representation of the rest of the ARN.
This method is essentially the reverse of
match_rest()
andassign_rest()
. By default returnsrest
. Override this method to allow users to override specific fields and get astr(...)
representation that includes the override.
-
Submodules¶
arn.ecs module¶
ARNs for AWS ECS.
-
class
arn.ecs.
NewOldEcsArnMixin
¶ Bases:
object
-
match_rest
(rest: str) → Match¶ Overridden to handle both ARN formats.
Tries to match a new-style ARN with cluster name and falls back to matching the ARN without the cluster name.
-
-
class
arn.ecs.
ClusterArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', name: str = '')¶ Bases:
arn.Arn
ARN for an ECS Cluster.
-
REST_PATTERN
= re.compile('cluster/(?P<name>.+)')¶
-
name
: str = ''¶
-
-
class
arn.ecs.
ContainerInstanceArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', cluster: str = '', id: str = '')¶ Bases:
arn.ecs.NewOldEcsArnMixin
,arn.Arn
ARN for an ECS Container Instance.
-
REST_PATTERN_WITHOUT_CLUSTER
= re.compile('container-instance/(?P<id>.+)')¶
-
REST_PATTERN_WITH_CLUSTER
= re.compile('container-instance/(?P<cluster>.*)/(?P<id>.+)')¶
-
cluster
: str = ''¶
-
id
: str = ''¶
-
format_rest
()¶ Overridden to handle both ARN formats.
If the ARN was originally parsed with the cluster name, it will be added to the formatted rest.
-
-
class
arn.ecs.
ServiceArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', cluster: str = '', service_name: str = '')¶ Bases:
arn.ecs.NewOldEcsArnMixin
,arn.Arn
ARN for an ECS Service.
-
REST_PATTERN_WITHOUT_CLUSTER
= re.compile('service/(?P<service_name>.*)')¶
-
REST_PATTERN_WITH_CLUSTER
= re.compile('service/(?P<cluster>.*)/(?P<service_name>.*)')¶
-
cluster
: str = ''¶
-
service_name
: str = ''¶
-
format_rest
()¶ Overridden to handle both ARN formats.
If the ARN was originally parsed with the cluster name, it will be added to the formatted rest.
-
-
class
arn.ecs.
TaskArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', cluster: str = '', id: str = '')¶ Bases:
arn.ecs.NewOldEcsArnMixin
,arn.Arn
ARN for an ECS Task.
-
REST_PATTERN_WITHOUT_CLUSTER
= re.compile('task/(?P<id>.+)')¶
-
REST_PATTERN_WITH_CLUSTER
= re.compile('task/(?P<cluster>.*)/(?P<id>.+)')¶
-
cluster
: str = ''¶
-
id
: str = ''¶
-
format_rest
()¶ Overridden to handle both ARN formats.
If the ARN was originally parsed with the cluster name, it will be added to the formatted rest.
-
-
class
arn.ecs.
TaskDefinitionArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', family: str = '', version: int = 0)¶ Bases:
arn.Arn
ARN for an ECS Task Definition.
-
REST_PATTERN
= re.compile('task-definition/(?P<family>.+):(?P<version>\\d+)')¶
-
family
: str = ''¶
-
version
: int = 0¶
-
assign_rest
(match: Match)¶ Assign an re.Match’s groups to fields on
self
.By default, assigns all named groups in
REST_PATTERN
as strings. Override this method to cast group matches to a more appropriate type. For an example, seearn.ecs.TaskDefinitionArn.assign_rest()
.
-
-
class
arn.ecs.
CapacityProviderArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', name: str = '')¶ Bases:
arn.Arn
ARN for an ECS Capacity Provider.
-
REST_PATTERN
= re.compile('capacity-provider/(?P<name>.+)')¶
-
name
: str = ''¶
-
-
class
arn.ecs.
TaskSetArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', cluster_name: str = '', service_name: str = '', id: str = '')¶ Bases:
arn.Arn
ARN for an ECS TaskSet.
-
REST_PATTERN
= re.compile('task-set/(?P<cluster_name>.+)/(?P<service_name>.+)/(?P<id>.+)')¶
-
cluster_name
: str = ''¶
-
service_name
: str = ''¶
-
id
: str = ''¶
-
arn.elbv2 module¶
ARNs for AWS ELBv2.
-
class
arn.elbv2.
LoadBalancer
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', type: str = '', name: str = '', id: str = '')¶ Bases:
arn.Arn
-
REST_PATTERN
= re.compile('loadbalancer/(?P<type>app|net)/(?P<name>.*)/(?P<id>.*)')¶
-
type
: str = ''¶ The type of load balancer,
app
for Application,net
for Network.
-
name
: str = ''¶
-
id
: str = ''¶
-
-
class
arn.elbv2.
LoadBalancerListener
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', load_balancer_type: str = '', load_balancer_name: str = '', load_balancer_id: str = '', listener_id: str = '')¶ Bases:
arn.Arn
ARN for ALB and NLB listeners.
-
REST_PATTERN
= re.compile('listener/(?P<load_balancer_type>app|net)/(?P<load_balancer_name>.*)/(?P<load_balancer_id>.*)/(?P<listener_id>.*)')¶
-
load_balancer_type
: str = ''¶ The type of load balancer,
app
for Application,net
for Network.
-
load_balancer_name
: str = ''¶
-
load_balancer_id
: str = ''¶
-
listener_id
: str = ''¶
-
-
class
arn.elbv2.
LoadBalancerListenerRule
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', load_balancer_type: str = '', load_balancer_name: str = '', load_balancer_id: str = '', listener_id: str = '', listener_rule_id: str = '')¶ Bases:
arn.Arn
ARN for ALB and NLB listener rules.
-
REST_PATTERN
= re.compile('listener-rule/(?P<load_balancer_type>app|net)/(?P<load_balancer_name>.*)/(?P<load_balancer_id>.*)/(?P<listener_id>.*)/(?P<listener_rule_id>.*)')¶
-
load_balancer_type
: str = ''¶ The type of load balancer,
app
for Application,net
for Network.
-
load_balancer_name
: str = ''¶
-
load_balancer_id
: str = ''¶
-
listener_id
: str = ''¶
-
listener_rule_id
: str = ''¶
-
arn.iam module¶
ARNs for AWS IAM and AWS STS <https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awssecuritytokenservice.html#awssecuritytokenservice-resources-for-iam-policies>_.
These two services are tightly coupled, and some ARNs exist in both or have inconsistent documentation (for example, the IAM docs show assumed-role with iam as the service, but the AWS API reference has sts as the service).
-
class
arn.iam.
RoleArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', name: str = '')¶ Bases:
arn.Arn
ARN for an IAM Role.
-
REST_PATTERN
= re.compile('role/(?P<name>.*)')¶
-
name
: str = ''¶
-
-
class
arn.iam.
AssumedRoleArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '', role_name: str = '', role_session_name: str = '')¶ Bases:
arn.Arn
ARN for an IAM/STS Assumed Role.
-
REST_PATTERN
= re.compile('assumed-role/(?P<role_name>.*)/(?P<role_session_name>.*)')¶
-
role_name
: str = ''¶
-
role_session_name
: str = ''¶
-
arn.s3 module¶
ARNs for AWS S3.
-
class
arn.s3.
AccessPointArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '')¶ Bases:
arn.Arn
ARN for an S3 Access Point.
-
REST_PATTERN
= re.compile('accesspoint/(?P<name>.*)')¶
-
name
: str = ''¶
-
-
class
arn.s3.
BucketArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '')¶ Bases:
arn.Arn
ARN for an S3 Bucket.
-
REST_PATTERN
= re.compile('(?P<name>.*)')¶
-
name
: str = ''¶
-
-
class
arn.s3.
ObjectArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '')¶ Bases:
arn.Arn
ARN for an S3 Object.
-
REST_PATTERN
= re.compile('(?P<bucket_name>.*)/(?P<object_name>.*)')¶
-
bucket_name
: str = ''¶
-
object_name
: str = ''¶
-
-
class
arn.s3.
JobArn
(input_arn: Any, partition: str = '', service: str = '', region: str = '', account: str = '')¶ Bases:
arn.Arn
ARN for an S3 Batch Job.
-
REST_PATTERN
= re.compile('job/(?P<id>.*)')¶
-
id
: str = ''¶
-