Skip to content

Commit 64e0962

Browse files
authored
Update I3510 to skip dynamic references (#4236)
1 parent 89ea045 commit 64e0962

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/cfnlint/rules/resources/iam/StatementResources.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
from collections import deque
1010
from typing import Any
1111

12+
import regex as re
13+
1214
from cfnlint.data import AdditionalSpecs
13-
from cfnlint.helpers import ensure_list, is_function, load_resource
15+
from cfnlint.helpers import REGEX_DYN_REF, ensure_list, is_function, load_resource
1416
from cfnlint.jsonschema import ValidationError, ValidationResult, Validator
1517
from cfnlint.rules.helpers import get_value_from_path
1618
from cfnlint.rules.jsonschema.CfnLintKeyword import CfnLintKeyword
@@ -105,7 +107,10 @@ def validate(
105107
resources = ensure_list(resources)
106108

107109
for resource in resources:
108-
if not isinstance(resource, str):
110+
if isinstance(resource, str):
111+
if re.match(REGEX_DYN_REF, resource):
112+
return
113+
else:
109114
k, v = is_function(resource)
110115
if k is None:
111116
continue

test/unit/rules/resources/iam/test_statement_resources.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ def template():
187187
# ),
188188
],
189189
),
190+
(
191+
{
192+
"Action": ["kms:Encrypt"],
193+
"Resource": ["{{resolve:ssm:/My/resources/kms_key_arn}}"],
194+
},
195+
[],
196+
),
190197
(
191198
{
192199
"Action": ["cloudformation:CreateStackSet"],

0 commit comments

Comments
 (0)