Skip to content

Commit

Permalink
Don't validate W2001 when using Transform (#3501)
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong authored Jul 13, 2024
1 parent ee6271f commit 2cc2226
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/cfnlint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging

from cfnlint.api import lint, lint_all
from cfnlint.config import ConfigMixIn
from cfnlint.config import ConfigMixIn, ManualArgs
from cfnlint.rules import Rules
from cfnlint.template import Template
from cfnlint.template.transforms import Transform
Expand Down
2 changes: 2 additions & 0 deletions src/cfnlint/rules/parameters/Used.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Used(CloudFormationLintRule):
tags = ["parameters"]

def match(self, cfn: Template) -> RuleMatches:
if cfn.transform_pre["Transform"]:
return []
matches: RuleMatches = []

le_refs = None
Expand Down
43 changes: 0 additions & 43 deletions test/fixtures/templates/bad/parameters/used_transform_removed.yaml

This file was deleted.

26 changes: 26 additions & 0 deletions test/fixtures/templates/good/parameters/not_used_parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Parameters:
Version:
Type: String

Resources:
SomeLambda:
Type: 'AWS::Serverless::Function'
Properties:
Handler: com.SomeLambda::handleRequest
Runtime: java8
MemorySize: 256
CodeUri:
Bucket: "somebucket"
Key: "lambda/code/lambda-shaded.jar"
LaunchConfiguration:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
ImageId: ami-123456
InstanceType: t2.micro
UserData:
'Fn::Base64':
'Fn::Sub':
'Fn::Transform': # Doesn't fail on Transform
Name: DynamicUserData
7 changes: 1 addition & 6 deletions test/unit/rules/parameters/test_used.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def setUp(self):
"test/fixtures/templates/good/parameters/used_transforms.yaml",
"test/fixtures/templates/good/parameters/used_transform_removed.yaml",
"test/fixtures/templates/good/parameters/used_transform_language_extension.json",
"test/fixtures/templates/good/parameters/not_used_parameters.yaml",
]

def test_file_positive(self):
Expand All @@ -30,9 +31,3 @@ def test_file_negative(self):
self.helper_file_negative(
"test/fixtures/templates/bad/parameters/configuration.yaml", 17
)

def test_file_negative_removed(self):
"""Test failure"""
self.helper_file_negative(
"test/fixtures/templates/bad/parameters/used_transform_removed.yaml", 1
)

0 comments on commit 2cc2226

Please sign in to comment.