Skip to content

Commit

Permalink
Set Application location when its a string (#3060)
Browse files Browse the repository at this point in the history
* Ignore W3002 will be ignored when the template has the SAM transform
  • Loading branch information
kddejong committed Feb 16, 2024
1 parent 7cabf20 commit 3398334
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/cfnlint/rules/resources/properties/PropertiesTemplated.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def match_resource_properties(self, properties, resourcetype, path, cfn):
"""Check CloudFormation Properties"""
matches = []

if cfn.has_serverless_transform():
return []

for key in self.templated_exceptions.get(resourcetype, []):
matches.extend(
cfn.check_value(
Expand Down
14 changes: 11 additions & 3 deletions src/cfnlint/template/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ def build_graph(self):

def has_language_extensions_transform(self):
"""Check if the template has language extensions transform declared"""
LOGGER.debug(
"Check if the template has language extensions transform declaration"
)
lang_extensions_transform = "AWS::LanguageExtensions"
transform_declaration = self.transform_pre["Transform"]
transform_type = (
Expand All @@ -106,6 +103,17 @@ def has_language_extensions_transform(self):
)
return bool(lang_extensions_transform in transform_type)

def has_serverless_transform(self):
"""Check if the template has SAM transform declared"""
lang_extensions_transform = "AWS::Serverless-2016-10-31"
transform_declaration = self.transform_pre["Transform"]
transform_type = (
transform_declaration
if isinstance(transform_declaration, list)
else [transform_declaration]
)
return bool(lang_extensions_transform in transform_type)

def get_resources(self, resource_type=[]):
"""
Get Resources
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Transform: AWS::Serverless-2016-10-31
Resources:
Function:
Type: AWS::Serverless::Application
Properties:
Location: path/
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def setUp(self):
super(TestPropertiesTemplated, self).setUp()
self.collection.register(PropertiesTemplated())
self.success_templates = [
"test/fixtures/templates/good/resources/properties/templated_code.yaml"
"test/fixtures/templates/good/resources/properties/templated_code.yaml",
"test/fixtures/templates/good/resources/properties/templated_code_sam.yaml",
]

def test_file_positive(self):
Expand Down

0 comments on commit 3398334

Please sign in to comment.