Skip to content

Commit de871c3

Browse files
authored
Update regex pattern for rule I3042 (#3572)
1 parent d4d7e2b commit de871c3

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/cfnlint/rules/resources/HardCodedArnProperties.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ class HardCodedArnProperties(CloudFormationLintRule):
2424
)
2525
source_url = ""
2626
tags = ["resources"]
27+
# using \r\n inside ${ } because there can be spaces in the sub parameter naming
28+
# using \s for matching outside of Sub parameters as no space will work
2729
regex = re.compile(
28-
r"arn:(\$\{[^:]*::[^:]*}|[^:]*):[^:]+:(\$\{[^:]*::[^:]*}|[^:]*):(\$\{[^:]*::[^:]*}|[^:]*)"
30+
r"arn:(\$\{[^:\r\n]*::[^:\r\n]*}|[^:\s]*):[^:\s]+:(\$\{[^:\r\n]*::[^:\r\n]*}|[^:\s]*):(\$\{[^:\r\n]*::[^:\r\n]*}|[^:\s]*)"
2931
)
3032

3133
def __init__(self):

test/fixtures/templates/good/resources/properties/hard_coded_arn_properties_sam.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
AWSTemplateFormatVersion: 2010-09-09
22
Transform: AWS::Serverless-2016-10-31
3+
Parameters:
4+
DynamoDBTableArn:
5+
Description: "DynamoDB Table ARN"
6+
Type: String
37
Resources:
48
S3BadBucket:
59
Type: AWS::S3::Bucket
@@ -78,3 +82,25 @@ Resources:
7882
- !Sub arn:${AWS::Partition}:sns:${AWS::Partition}:${AWS::AccountId}:TestTopic
7983
Roles:
8084
- !Ref SampleRole
85+
86+
IngestionPipeline:
87+
Type: AWS::OSIS::Pipeline
88+
Properties:
89+
PipelineName: mypipeline
90+
MaxUnits: 1
91+
MinUnits: 1
92+
PipelineConfigurationBody: !Sub |
93+
version: "2"
94+
dynamodb-pipeline:
95+
source:
96+
dynamodb:
97+
acknowledgments: true
98+
tables:
99+
- table_arn: ${DynamoDBTableArn}
100+
- export:
101+
s3_bucket: mybucket
102+
s3_prefix: prod
103+
stream:
104+
start_position: "LATEST"
105+
aws:
106+
region: us-east-1

0 commit comments

Comments
 (0)