Skip to content

Commit

Permalink
Put in an exception for TemplateBody for a nested stack (#2057)
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Jun 18, 2021
1 parent 1b2d9d2 commit 4dc8e2b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cfnlint/rules/functions/SubNeeded.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class SubNeeded(CloudFormationLintRule):
source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html'
tags = ['functions', 'sub']

exceptions = ['TemplateBody']

def __init__(self):
"""Init"""
super(SubNeeded, self).__init__()
Expand Down Expand Up @@ -111,7 +113,7 @@ def match(self, cfn):
var_stripped = var[2:-1].strip()

# If we didn't find an 'Fn::Sub' it means a string containing a ${parameter} may not be evaluated correctly
if not 'Fn::Sub' in parameter_string_path:
if not 'Fn::Sub' in parameter_string_path and parameter_string_path[-2] not in self.exceptions:
if (var_stripped in refs or var_stripped in getatts) or 'DefinitionString' in parameter_string_path:
# Remove the last item (the variable) to prevent multiple errors on 1 line errors
path = parameter_string_path[:-1]
Expand Down

0 comments on commit 4dc8e2b

Please sign in to comment.