Skip to content

Commit bca843e

Browse files
committed
Adding elasticloadbalancing ARNs
1 parent 3f22c2a commit bca843e

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/compose_x_common/aws/arns.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
from compose_x_common.aws.ecs.services import SERVICE_ARN_RE
1212
from compose_x_common.aws.efs import EFS_ARN_RE
1313
from compose_x_common.aws.elasticache import CACHE_CLUSTER_ARN_RE
14+
from compose_x_common.aws.elasticloadbalancing import (
15+
LB_V2_LB_ARN_RE,
16+
LB_V2_LISTENER_ARN_RE,
17+
LB_V2_LISTENER_RULE_ARN_RE,
18+
LB_V2_TGT_GROUP_ARN_RE,
19+
)
1420
from compose_x_common.aws.glue import GLUE_SR_ARN_RE
1521
from compose_x_common.aws.iam import IAM_ROLE_ARN_RE, IAM_USER_ARN_RE
1622
from compose_x_common.aws.kinesis import KINESIS_FIREHOSE_ARN_RE, KINESIS_STREAM_ARN_RE
@@ -65,6 +71,10 @@
6571
"AWS::APS::Workspace": APS_WORKSPACE_ARN_RE,
6672
"AWS::WAFv2::WebACL": WAF_V2_WEB_ACL_ARN_RE,
6773
"AWS::EFS::FileSystem": EFS_ARN_RE,
74+
"AWS::ElasticLoadBalancingV2::LoadBalancer": LB_V2_LB_ARN_RE,
75+
"AWS::ElasticLoadBalancingV2::ListenerRule": LB_V2_LISTENER_RULE_ARN_RE,
76+
"AWS::ElasticLoadBalancingV2::Listener": LB_V2_LISTENER_ARN_RE,
77+
"AWS::ElasticLoadBalancingV2::TargetGroup": LB_V2_TGT_GROUP_ARN_RE,
6878
}
6979

7080
ARNS_PER_TAGGINGAPI_TYPE = {
@@ -91,4 +101,8 @@
91101
"kafka:cluster": MSK_CLUSTER_ARN_RE,
92102
"aps:workspace": APS_WORKSPACE_ARN_RE,
93103
"elasticfilesystem": EFS_ARN_RE,
104+
"elasticloadbalancing:loadbalancer": LB_V2_LB_ARN_RE,
105+
"elasticloadbalancing:listener": LB_V2_LISTENER_ARN_RE,
106+
"elasticloadbalancing:listener-rule": LB_V2_LISTENER_RULE_ARN_RE,
107+
"elasticloadbalancing:targetgroup": LB_V2_TGT_GROUP_ARN_RE,
94108
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-License-Identifier: MPL-2.0
2+
# Copyright 2020-2024 John Mille <[email protected]>
3+
4+
"""ELB Helper functions"""
5+
6+
import re
7+
8+
LB_V2_LB_ARN_RE = re.compile(
9+
r"^arn:aws(?:-[a-z]+)?:elasticloadbalancing:(?P<region>[a-z\d\-]+-\d):(?P<accountid>[\d]{12}):"
10+
r"loadbalancer/(?P<type>net|app)/(?P<id>[\S]+)$"
11+
)
12+
13+
LB_V2_LISTENER_ARN_RE = re.compile(
14+
r"^arn:aws(?:-[a-z]+)?:elasticloadbalancing:(?P<region>[a-z\d\-]+-\d):(?P<accountid>[\d]{12}):"
15+
r"listener/(?P<type>net|app)/(?P<id>[\S]+)$"
16+
)
17+
18+
LB_V2_LISTENER_RULE_ARN_RE = re.compile(
19+
r"^arn:aws(?:-[a-z]+)?:elasticloadbalancing:(?P<region>[a-z\d\-]+-\d):(?P<accountid>[\d]{12}):"
20+
r"listener-rule/(?P<type>net|app)/(?P<id>[\S]+)$"
21+
)
22+
23+
LB_V2_TGT_GROUP_ARN_RE = re.compile(
24+
r"^arn:aws(?:-[a-z]+)?:elasticloadbalancing:(?P<region>[a-z\d\-]+-\d):(?P<accountid>[\d]{12}):"
25+
r"targetgroup/(?P<id>[\S]+)$"
26+
)

tests/test_arns.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def valid_arns():
4040
"AWS::Glue::Registry": "arn:aws:glue:us-east-2:012345678912:registry/registryname-1",
4141
"AWS::WAFv2::WebACL": "arn:aws:wafv2:eu-west-1:012345678912:regional/webacl/wafv2-webacl-dev/732c1718-ea9f-4370-a2a9-607f948a3cd7",
4242
"AWS::EFS::FileSystem": "arn:aws:elasticfilesystem:eu-west-1:108833517019:file-system/fs-08a8676339b99dc0a",
43+
"AWS::ElasticLoadBalancingV2::LoadBalancer": "arn:aws:elasticloadbalancing:eu-west-1:012345678912:loadbalancer/app/dummy/30005cdd5fd8886d",
44+
"AWS::ElasticLoadBalancingV2::ListenerRule": "arn:aws:elasticloadbalancing:eu-west-1:012345678912:listener-rule/app/dummy/30005cdd5fd8886d/8a449b15a6b1fcfb/28c19045fad0a1c4",
45+
"AWS::ElasticLoadBalancingV2::Listener": "arn:aws:elasticloadbalancing:eu-west-1:012345678912:listener/app/dummy/30005cdd5fd8886d/8a449b15a6b1fcfb",
46+
"AWS::ElasticLoadBalancingV2::TargetGroup": "arn:aws:elasticloadbalancing:eu-west-1:012345678912:targetgroup/dummy/8bd3dc4e967a9b9b",
4347
}
4448

4549

0 commit comments

Comments
 (0)