Skip to content

Commit 3398334

Browse files
authored
Set Application location when its a string (#3060)
* Ignore W3002 will be ignored when the template has the SAM transform
1 parent 7cabf20 commit 3398334

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

src/cfnlint/rules/resources/properties/PropertiesTemplated.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def match_resource_properties(self, properties, resourcetype, path, cfn):
6060
"""Check CloudFormation Properties"""
6161
matches = []
6262

63+
if cfn.has_serverless_transform():
64+
return []
65+
6366
for key in self.templated_exceptions.get(resourcetype, []):
6467
matches.extend(
6568
cfn.check_value(

src/cfnlint/template/template.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ def build_graph(self):
9494

9595
def has_language_extensions_transform(self):
9696
"""Check if the template has language extensions transform declared"""
97-
LOGGER.debug(
98-
"Check if the template has language extensions transform declaration"
99-
)
10097
lang_extensions_transform = "AWS::LanguageExtensions"
10198
transform_declaration = self.transform_pre["Transform"]
10299
transform_type = (
@@ -106,6 +103,17 @@ def has_language_extensions_transform(self):
106103
)
107104
return bool(lang_extensions_transform in transform_type)
108105

106+
def has_serverless_transform(self):
107+
"""Check if the template has SAM transform declared"""
108+
lang_extensions_transform = "AWS::Serverless-2016-10-31"
109+
transform_declaration = self.transform_pre["Transform"]
110+
transform_type = (
111+
transform_declaration
112+
if isinstance(transform_declaration, list)
113+
else [transform_declaration]
114+
)
115+
return bool(lang_extensions_transform in transform_type)
116+
109117
def get_resources(self, resource_type=[]):
110118
"""
111119
Get Resources
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Transform: AWS::Serverless-2016-10-31
2+
Resources:
3+
Function:
4+
Type: AWS::Serverless::Application
5+
Properties:
6+
Location: path/

test/unit/rules/resources/properties/test_properties_templated.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def setUp(self):
1818
super(TestPropertiesTemplated, self).setUp()
1919
self.collection.register(PropertiesTemplated())
2020
self.success_templates = [
21-
"test/fixtures/templates/good/resources/properties/templated_code.yaml"
21+
"test/fixtures/templates/good/resources/properties/templated_code.yaml",
22+
"test/fixtures/templates/good/resources/properties/templated_code_sam.yaml",
2223
]
2324

2425
def test_file_positive(self):

0 commit comments

Comments
 (0)