Skip to content

Commit 1568d9c

Browse files
committed
Added AWS::WAFv2::WebACL regular expressions
1 parent 509a396 commit 1568d9c

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/compose_x_common/aws/arns.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from compose_x_common.aws.sqs import SQS_QUEUE_ARN_RE
2626
from compose_x_common.aws.ssm_parameter import SSM_PARAMETER_ARN_RE
2727
from compose_x_common.aws.vpc import SUBNET_ARN_RE, VPC_ARN_RE
28+
from compose_x_common.aws.wafv2 import WAF_V2_WEB_ACL_ARN_RE
2829

2930
ARNS_PER_CFN_TYPE = {
3031
"AWS::IAM::Role": IAM_ROLE_ARN_RE,
@@ -61,6 +62,7 @@
6162
"AWS::MSK::ServerlessCluster": MSK_CLUSTER_ARN_RE,
6263
"AWS::Glue::Registry": GLUE_SR_ARN_RE,
6364
"AWS::APS::Workspace": APS_WORKSPACE_ARN_RE,
65+
"AWS::WAFv2::WebACL": WAF_V2_WEB_ACL_ARN_RE,
6466
}
6567

6668
ARNS_PER_TAGGINGAPI_TYPE = {

src/compose_x_common/aws/wafv2.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-License-Identifier: MPL-2.0
2+
# Copyright 2020-2023 John Mille <[email protected]>
3+
4+
"""AWS::WAFv2::"""
5+
6+
import re
7+
8+
WAF_V2_WEB_ACL_ARN_RE = re.compile(
9+
r"^arn:aws(?P<partition>-[a-z]+)?:wafv2:(?P<region>[a-z\d\-]+-\d):(?P<accountid>[\d]{12}):"
10+
r"(?P<scope>regional|global)/webacl/(?P<name>[\w\-_]+)/(?P<id>[\S]+)$"
11+
)
12+
13+
WAF_V2_WEB_ACL_REF_RE = re.compile(
14+
r"^(?P<name>[\w\-_]+)\|(?P<id>[\w\-]+)\|(?P<scope>REGIONAL|GLOBAL)$"
15+
)
16+
WAF_V2_WEB_ACL_NAMESPACE_PREFIX_RE = re.compile(
17+
r"^awswaf:\d{12}:webacl:(?P<name>[\w\-_]+):"
18+
)

tests/test_arns.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def valid_arns():
3838
"AWS::MSK::ServerlessCluster": "arn:aws:kafka:eu-west-1:123456789012:cluster/demo-cluster-1/d7e68213-0896-4839-80df-dea01b79750c-s1",
3939
"AWS::MSK::Configuration": "arn:aws:kafka:eu-west-1:123456789012:configuration/default-msk-331/e44a32b9-4cba-4686-a1e4-b0e72fb1baa4-8",
4040
"AWS::Glue::Registry": "arn:aws:glue:us-east-2:012345678912:registry/registryname-1",
41+
"AWS::WAFv2::WebACL": "arn:aws:wafv2:eu-west-1:012345678912:regional/webacl/wafv2-webacl-dev/732c1718-ea9f-4370-a2a9-607f948a3cd7",
4142
}
4243

4344

0 commit comments

Comments
 (0)