Skip to content

Commit b4b7e4e

Browse files
authored
Allow asterisks for rule I3042 (#3954)
1 parent f6952aa commit b4b7e4e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/cfnlint/rules/resources/HardCodedArnProperties.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def match(self, cfn: Template) -> RuleMatches:
101101
# !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
102102
# is valid even with aws as the account #. This handles empty string
103103
if self.config["partition"] and not re.match(
104-
r"^\$\{\w+}|\$\{AWS::Partition}|$", candidate[0]
104+
r"^\$\{\w+}|\$\{AWS::Partition}|\*|$", candidate[0]
105105
):
106106
# or not re.match(r'^(\$\{\w+}|\$\{AWS::Region}|)$',candidate[1])
107107
# or not re.match(r'^\$\{\w+}|\$\{AWS::AccountId}|aws|$', candidate[2]):
@@ -111,7 +111,7 @@ def match(self, cfn: Template) -> RuleMatches:
111111
)
112112
matches.append(RuleMatch(path, message.format(path[1])))
113113
if self.config["region"] and not re.match(
114-
r"^(\$\{\w+}|\$\{AWS::Region}|)$", candidate[1]
114+
r"^(\$\{\w+}|\$\{AWS::Region}|\*|)$", candidate[1]
115115
):
116116
# or or not re.match(r'^\$\{\w+}|\$\{AWS::AccountId}|aws|$', candidate[2]):
117117
message = (
@@ -123,7 +123,7 @@ def match(self, cfn: Template) -> RuleMatches:
123123
# Lambda is added for authorizer's Uniform Resource Identifier (URI)
124124
# https://github.com/aws-cloudformation/cfn-lint/issues/3716
125125
if self.config["accountId"] and not re.match(
126-
r"^\$\{\w+}|\$\{AWS::AccountId}|aws|lambda|$", candidate[2]
126+
r"^\$\{\w+}|\$\{AWS::AccountId}|aws|lambda|\*|$", candidate[2]
127127
):
128128
if candidate[2] not in ["cloudfront"]:
129129
message = (

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@ Resources:
2626
AWS: !Sub arn:${AWS::Partition}:iam::cloudfront:user/CloudFront Origin Access Identity E15MNIMTCFKK4C
2727
Action: s3:GetObject
2828
Resource: arn:aws:s3:::bucket/*
29+
Policy:
30+
Type: AWS::IAM::ManagedPolicy
31+
Properties:
32+
PolicyDocument:
33+
Version: "2012-10-17"
34+
Statement:
35+
- Effect: "Allow"
36+
Action: "*"
37+
Resource:
38+
- !Sub "arn:*:quicksight:${AWS::Region}:${AWS::AccountId}:dataset/*"
39+
- !Sub "arn:${AWS::Partition}:quicksight:*:${AWS::AccountId}:dataset/*"
40+
- !Sub "arn:${AWS::Partition}:quicksight:${AWS::Region}:*:dataset/*"

0 commit comments

Comments
 (0)