Skip to content

Commit a9aaffd

Browse files
authored
Update I3510 to only validate one resource is matched (#4032)
1 parent 7351d0c commit a9aaffd

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

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

+11-9
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,17 @@ def validate(
158158
].get("ARNFormats")
159159
for arn_format in arn_formats:
160160
arn = _Arn(arn_format)
161-
if arn not in all_resource_arns:
162-
yield ValidationError(
163-
(
164-
f"action {action!r} requires "
165-
f"a resource of {arn_formats!r}"
166-
),
167-
path=deque(["Resource"]),
168-
rule=self,
169-
)
161+
if arn in all_resource_arns:
162+
break
163+
else:
164+
yield ValidationError(
165+
(
166+
f"action {action!r} requires "
167+
f"a resource of {arn_formats!r}"
168+
),
169+
path=deque(["Resource"]),
170+
rule=self,
171+
)
170172
else:
171173
LOGGER.debug(f"action {action!r} requires a resource of '*'")
172174
# yield ValidationError(

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

+7
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ def template():
112112
},
113113
[],
114114
),
115+
(
116+
{
117+
"Action": "ec2:CreateTags",
118+
"Resource": ["arn:aws:ec2:*::snapshot/*"],
119+
},
120+
[],
121+
),
115122
(
116123
{
117124
"Action": "cloudformation:CreateStackSet",

0 commit comments

Comments
 (0)