We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Outside of an Sub error for arn:aws:s3:::${transfer:HomeBucket}
*cfn-lint version:  0.21.5*

*Description of issue.*
When defining a scope down policy for AWS SFTP transfer, cfn-lint gives error **E1029 Found an embedded parameter outside of an "Fn::Sub"** on things like `arn:aws:s3:::${transfer:HomeBucket}`. Is there anyway to exclude those?

```yaml
  SftpScopeDownPolicy:
    Type: AWS::IAM::ManagedPolicy
    Properties:
      Description: Policy for restricting SFTP users to have access to only their home directory
      ManagedPolicyName: sftp-scope-down-policy
      PolicyDocument:
        Version: "2012-10-17"
        Statement:
          -
            Sid: AllowListingOfUserFolder
            Effect: Allow
            Action:
              - s3:ListBucket
            Resource: arn:aws:s3:::${transfer:HomeBucket}
            Condition:
              StringLike:
                s3:prefix:
                  - '${transfer:HomeFolder}'
                  - '${transfer:HomeFolder}/*'
          -
            Sid: HomeDirectoryObjectAccess
            Effect: Allow
            Action:
              - s3:GetObject
              - s3:GetObjectVersion
              - s3:PutObject
              - s3:DeleteObject
              - s3:DeleteObjectVersion
              - s3:GetObjectACL
            Resource: arn:aws:s3:::${transfer:HomeDirectory}*
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cfnlint/rules/functions/SubNeeded.py`
Content:
```
1 """
2   Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 
4   Permission is hereby granted, free of charge, to any person obtaining a copy of this
5   software and associated documentation files (the "Software"), to deal in the Software
6   without restriction, including without limitation the rights to use, copy, modify,
7   merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
8   permit persons to whom the Software is furnished to do so.
9 
10   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
11   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
12   PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
13   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
14   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 """
17 import re
18 from cfnlint import CloudFormationLintRule
19 from cfnlint import RuleMatch
20 
21 class SubNeeded(CloudFormationLintRule):
22     """Check if a substitution string exists without a substitution function"""
23     id = 'E1029'
24     shortdesc = 'Sub is required if a variable is used in a string'
25     description = 'If a substitution variable exists in a string but isn\'t wrapped with the Fn::Sub function the deployment will fail.'
26     source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html'
27     tags = ['functions', 'sub']
28 
29     # Free-form text properties to exclude from this rule
30     # content is part of AWS::CloudFormation::Init
31     excludes = ['UserData', 'ZipFile', 'Condition', 'AWS::CloudFormation::Init', 'CloudWatchAlarmDefinition']
32     api_excludes = ['Uri', 'Body']
33 
34     # IAM Policy has special variables that don't require !Sub, Check for these
35     # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html
36     # https://docs.aws.amazon.com/iot/latest/developerguide/basic-policy-variables.html
37     # https://docs.aws.amazon.com/iot/latest/developerguide/thing-policy-variables.html
38     resource_excludes = ['${aws:CurrentTime}', '${aws:EpochTime}', '${aws:TokenIssueTime}', '${aws:principaltype}',
39                          '${aws:SecureTransport}', '${aws:SourceIp}', '${aws:UserAgent}', '${aws:userid}',
40                          '${aws:username}', '${ec2:SourceInstanceARN}',
41                          '${iot:Connection.Thing.ThingName}', '${iot:Connection.Thing.ThingTypeName}',
42                          '${iot:Connection.Thing.IsAttached}', '${iot:ClientId}']
43 
44     def _match_values(self, searchRegex, cfnelem, path):
45         """Recursively search for values matching the searchRegex"""
46         values = []
47         if isinstance(cfnelem, dict):
48             for key in cfnelem:
49                 pathprop = path[:]
50                 pathprop.append(key)
51                 values.extend(self._match_values(searchRegex, cfnelem[key], pathprop))
52         elif isinstance(cfnelem, list):
53             for index, item in enumerate(cfnelem):
54                 pathprop = path[:]
55                 pathprop.append(index)
56                 values.extend(self._match_values(searchRegex, item, pathprop))
57         else:
58             # Leaf node
59             if isinstance(cfnelem, str) and re.match(searchRegex, cfnelem):
60                 # Get all variables as seperate paths
61                 regex = re.compile(r'(\$\{.*?\.?.*?})')
62                 for variable in re.findall(regex, cfnelem):
63                     values.append(path + [variable])
64 
65         return values
66 
67     def match_values(self, searchRegex, cfn):
68         """
69             Search for values in all parts of the templates that match the searchRegex
70         """
71         results = []
72         results.extend(self._match_values(searchRegex, cfn.template, []))
73         # Globals are removed during a transform.  They need to be checked manually
74         results.extend(self._match_values(searchRegex, cfn.template.get('Globals', {}), []))
75         return results
76 
77     def _api_exceptions(self, value):
78         """ Key value exceptions """
79         parameter_search = re.compile(r'^\$\{stageVariables\..*\}$')
80         return re.match(parameter_search, value)
81 
82     def match(self, cfn):
83         """Basic Rule Matching"""
84 
85         matches = []
86 
87         # Generic regex to match a string containing at least one ${parameter}
88         parameter_search = re.compile(r'^.*(\$\{.*\}.*(\$\{.*\}.*)*)$')
89 
90         # Get a list of paths to every leaf node string containing at least one ${parameter}
91         parameter_string_paths = self.match_values(parameter_search, cfn)
92 
93         # We want to search all of the paths to check if each one contains an 'Fn::Sub'
94         for parameter_string_path in parameter_string_paths:
95 
96             # Exxclude the special IAM variables
97             variable = parameter_string_path[-1]
98 
99             if 'Resource' in parameter_string_path:
100                 if variable in self.resource_excludes:
101                     continue
102 
103             # Exclude literals (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html)
104             if variable.startswith('${!'):
105                 continue
106 
107             found_sub = False
108             # Does the path contain an 'Fn::Sub'?
109             for step in parameter_string_path:
110                 if step in self.api_excludes:
111                     if self._api_exceptions(parameter_string_path[-1]):
112                         found_sub = True
113                 elif step == 'Fn::Sub' or step in self.excludes:
114                     found_sub = True
115 
116             # If we didn't find an 'Fn::Sub' it means a string containing a ${parameter} may not be evaluated correctly
117             if not found_sub:
118                 # Remove the last item (the variable) to prevent multiple errors on 1 line errors
119                 path = parameter_string_path[:-1]
120                 message = 'Found an embedded parameter outside of an "Fn::Sub" at {}'.format('/'.join(map(str, path)))
121                 matches.append(RuleMatch(path, message))
122 
123         return matches
124
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/cfnlint/rules/functions/SubNeeded.py b/src/cfnlint/rules/functions/SubNeeded.py
--- a/src/cfnlint/rules/functions/SubNeeded.py
+++ b/src/cfnlint/rules/functions/SubNeeded.py
@@ -35,11 +35,13 @@
     # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html
     # https://docs.aws.amazon.com/iot/latest/developerguide/basic-policy-variables.html
     # https://docs.aws.amazon.com/iot/latest/developerguide/thing-policy-variables.html
+    # https://docs.aws.amazon.com/transfer/latest/userguide/users.html#users-policies-scope-down
     resource_excludes = ['${aws:CurrentTime}', '${aws:EpochTime}', '${aws:TokenIssueTime}', '${aws:principaltype}',
                          '${aws:SecureTransport}', '${aws:SourceIp}', '${aws:UserAgent}', '${aws:userid}',
                          '${aws:username}', '${ec2:SourceInstanceARN}',
                          '${iot:Connection.Thing.ThingName}', '${iot:Connection.Thing.ThingTypeName}',
-                         '${iot:Connection.Thing.IsAttached}', '${iot:ClientId}']
+                         '${iot:Connection.Thing.IsAttached}', '${iot:ClientId}', '${transfer:HomeBucket}',
+                         '${transfer:HomeDirectory}', '${transfer:HomeFolder}', '${transfer:UserName}']
 
     def _match_values(self, searchRegex, cfnelem, path):
         """Recursively search for values matching the searchRegex"""

{"golden_diff": "diff --git a/src/cfnlint/rules/functions/SubNeeded.py b/src/cfnlint/rules/functions/SubNeeded.py\n--- a/src/cfnlint/rules/functions/SubNeeded.py\n+++ b/src/cfnlint/rules/functions/SubNeeded.py\n@@ -35,11 +35,13 @@\n     # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html\n     # https://docs.aws.amazon.com/iot/latest/developerguide/basic-policy-variables.html\n     # https://docs.aws.amazon.com/iot/latest/developerguide/thing-policy-variables.html\n+    # https://docs.aws.amazon.com/transfer/latest/userguide/users.html#users-policies-scope-down\n     resource_excludes = ['${aws:CurrentTime}', '${aws:EpochTime}', '${aws:TokenIssueTime}', '${aws:principaltype}',\n                          '${aws:SecureTransport}', '${aws:SourceIp}', '${aws:UserAgent}', '${aws:userid}',\n                          '${aws:username}', '${ec2:SourceInstanceARN}',\n                          '${iot:Connection.Thing.ThingName}', '${iot:Connection.Thing.ThingTypeName}',\n-                         '${iot:Connection.Thing.IsAttached}', '${iot:ClientId}']\n+                         '${iot:Connection.Thing.IsAttached}', '${iot:ClientId}', '${transfer:HomeBucket}',\n+                         '${transfer:HomeDirectory}', '${transfer:HomeFolder}', '${transfer:UserName}']\n \n     def _match_values(self, searchRegex, cfnelem, path):\n         \"\"\"Recursively search for values matching the searchRegex\"\"\"\n", "issue": "Outside of an Sub error for arn:aws:s3:::${transfer:HomeBucket}\n*cfn-lint version:  0.21.5*\r\n\r\n*Description of issue.*\r\nWhen defining a scope down policy for AWS SFTP transfer, cfn-lint gives error **E1029 Found an embedded parameter outside of an \"Fn::Sub\"** on things like `arn:aws:s3:::${transfer:HomeBucket}`. Is there anyway to exclude those?\r\n\r\n```yaml\r\n  SftpScopeDownPolicy:\r\n    Type: AWS::IAM::ManagedPolicy\r\n    Properties:\r\n      Description: Policy for restricting SFTP users to have access to only their home directory\r\n      ManagedPolicyName: sftp-scope-down-policy\r\n      PolicyDocument:\r\n        Version: \"2012-10-17\"\r\n        Statement:\r\n          -\r\n            Sid: AllowListingOfUserFolder\r\n            Effect: Allow\r\n            Action:\r\n              - s3:ListBucket\r\n            Resource: arn:aws:s3:::${transfer:HomeBucket}\r\n            Condition:\r\n              StringLike:\r\n                s3:prefix:\r\n                  - '${transfer:HomeFolder}'\r\n                  - '${transfer:HomeFolder}/*'\r\n          -\r\n            Sid: HomeDirectoryObjectAccess\r\n            Effect: Allow\r\n            Action:\r\n              - s3:GetObject\r\n              - s3:GetObjectVersion\r\n              - s3:PutObject\r\n              - s3:DeleteObject\r\n              - s3:DeleteObjectVersion\r\n              - s3:GetObjectACL\r\n            Resource: arn:aws:s3:::${transfer:HomeDirectory}*\r\n```\r\n\n", "before_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport re\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\nclass SubNeeded(CloudFormationLintRule):\n    \"\"\"Check if a substitution string exists without a substitution function\"\"\"\n    id = 'E1029'\n    shortdesc = 'Sub is required if a variable is used in a string'\n    description = 'If a substitution variable exists in a string but isn\\'t wrapped with the Fn::Sub function the deployment will fail.'\n    source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html'\n    tags = ['functions', 'sub']\n\n    # Free-form text properties to exclude from this rule\n    # content is part of AWS::CloudFormation::Init\n    excludes = ['UserData', 'ZipFile', 'Condition', 'AWS::CloudFormation::Init', 'CloudWatchAlarmDefinition']\n    api_excludes = ['Uri', 'Body']\n\n    # IAM Policy has special variables that don't require !Sub, Check for these\n    # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html\n    # https://docs.aws.amazon.com/iot/latest/developerguide/basic-policy-variables.html\n    # https://docs.aws.amazon.com/iot/latest/developerguide/thing-policy-variables.html\n    resource_excludes = ['${aws:CurrentTime}', '${aws:EpochTime}', '${aws:TokenIssueTime}', '${aws:principaltype}',\n                         '${aws:SecureTransport}', '${aws:SourceIp}', '${aws:UserAgent}', '${aws:userid}',\n                         '${aws:username}', '${ec2:SourceInstanceARN}',\n                         '${iot:Connection.Thing.ThingName}', '${iot:Connection.Thing.ThingTypeName}',\n                         '${iot:Connection.Thing.IsAttached}', '${iot:ClientId}']\n\n    def _match_values(self, searchRegex, cfnelem, path):\n        \"\"\"Recursively search for values matching the searchRegex\"\"\"\n        values = []\n        if isinstance(cfnelem, dict):\n            for key in cfnelem:\n                pathprop = path[:]\n                pathprop.append(key)\n                values.extend(self._match_values(searchRegex, cfnelem[key], pathprop))\n        elif isinstance(cfnelem, list):\n            for index, item in enumerate(cfnelem):\n                pathprop = path[:]\n                pathprop.append(index)\n                values.extend(self._match_values(searchRegex, item, pathprop))\n        else:\n            # Leaf node\n            if isinstance(cfnelem, str) and re.match(searchRegex, cfnelem):\n                # Get all variables as seperate paths\n                regex = re.compile(r'(\\$\\{.*?\\.?.*?})')\n                for variable in re.findall(regex, cfnelem):\n                    values.append(path + [variable])\n\n        return values\n\n    def match_values(self, searchRegex, cfn):\n        \"\"\"\n            Search for values in all parts of the templates that match the searchRegex\n        \"\"\"\n        results = []\n        results.extend(self._match_values(searchRegex, cfn.template, []))\n        # Globals are removed during a transform.  They need to be checked manually\n        results.extend(self._match_values(searchRegex, cfn.template.get('Globals', {}), []))\n        return results\n\n    def _api_exceptions(self, value):\n        \"\"\" Key value exceptions \"\"\"\n        parameter_search = re.compile(r'^\\$\\{stageVariables\\..*\\}$')\n        return re.match(parameter_search, value)\n\n    def match(self, cfn):\n        \"\"\"Basic Rule Matching\"\"\"\n\n        matches = []\n\n        # Generic regex to match a string containing at least one ${parameter}\n        parameter_search = re.compile(r'^.*(\\$\\{.*\\}.*(\\$\\{.*\\}.*)*)$')\n\n        # Get a list of paths to every leaf node string containing at least one ${parameter}\n        parameter_string_paths = self.match_values(parameter_search, cfn)\n\n        # We want to search all of the paths to check if each one contains an 'Fn::Sub'\n        for parameter_string_path in parameter_string_paths:\n\n            # Exxclude the special IAM variables\n            variable = parameter_string_path[-1]\n\n            if 'Resource' in parameter_string_path:\n                if variable in self.resource_excludes:\n                    continue\n\n            # Exclude literals (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html)\n            if variable.startswith('${!'):\n                continue\n\n            found_sub = False\n            # Does the path contain an 'Fn::Sub'?\n            for step in parameter_string_path:\n                if step in self.api_excludes:\n                    if self._api_exceptions(parameter_string_path[-1]):\n                        found_sub = True\n                elif step == 'Fn::Sub' or step in self.excludes:\n                    found_sub = True\n\n            # If we didn't find an 'Fn::Sub' it means a string containing a ${parameter} may not be evaluated correctly\n            if not found_sub:\n                # Remove the last item (the variable) to prevent multiple errors on 1 line errors\n                path = parameter_string_path[:-1]\n                message = 'Found an embedded parameter outside of an \"Fn::Sub\" at {}'.format('/'.join(map(str, path)))\n                matches.append(RuleMatch(path, message))\n\n        return matches\n", "path": "src/cfnlint/rules/functions/SubNeeded.py"}], "after_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport re\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint import RuleMatch\n\nclass SubNeeded(CloudFormationLintRule):\n    \"\"\"Check if a substitution string exists without a substitution function\"\"\"\n    id = 'E1029'\n    shortdesc = 'Sub is required if a variable is used in a string'\n    description = 'If a substitution variable exists in a string but isn\\'t wrapped with the Fn::Sub function the deployment will fail.'\n    source_url = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html'\n    tags = ['functions', 'sub']\n\n    # Free-form text properties to exclude from this rule\n    # content is part of AWS::CloudFormation::Init\n    excludes = ['UserData', 'ZipFile', 'Condition', 'AWS::CloudFormation::Init', 'CloudWatchAlarmDefinition']\n    api_excludes = ['Uri', 'Body']\n\n    # IAM Policy has special variables that don't require !Sub, Check for these\n    # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html\n    # https://docs.aws.amazon.com/iot/latest/developerguide/basic-policy-variables.html\n    # https://docs.aws.amazon.com/iot/latest/developerguide/thing-policy-variables.html\n    # https://docs.aws.amazon.com/transfer/latest/userguide/users.html#users-policies-scope-down\n    resource_excludes = ['${aws:CurrentTime}', '${aws:EpochTime}', '${aws:TokenIssueTime}', '${aws:principaltype}',\n                         '${aws:SecureTransport}', '${aws:SourceIp}', '${aws:UserAgent}', '${aws:userid}',\n                         '${aws:username}', '${ec2:SourceInstanceARN}',\n                         '${iot:Connection.Thing.ThingName}', '${iot:Connection.Thing.ThingTypeName}',\n                         '${iot:Connection.Thing.IsAttached}', '${iot:ClientId}', '${transfer:HomeBucket}',\n                         '${transfer:HomeDirectory}', '${transfer:HomeFolder}', '${transfer:UserName}']\n\n    def _match_values(self, searchRegex, cfnelem, path):\n        \"\"\"Recursively search for values matching the searchRegex\"\"\"\n        values = []\n        if isinstance(cfnelem, dict):\n            for key in cfnelem:\n                pathprop = path[:]\n                pathprop.append(key)\n                values.extend(self._match_values(searchRegex, cfnelem[key], pathprop))\n        elif isinstance(cfnelem, list):\n            for index, item in enumerate(cfnelem):\n                pathprop = path[:]\n                pathprop.append(index)\n                values.extend(self._match_values(searchRegex, item, pathprop))\n        else:\n            # Leaf node\n            if isinstance(cfnelem, str) and re.match(searchRegex, cfnelem):\n                # Get all variables as seperate paths\n                regex = re.compile(r'(\\$\\{.*?\\.?.*?})')\n                for variable in re.findall(regex, cfnelem):\n                    values.append(path + [variable])\n\n        return values\n\n    def match_values(self, searchRegex, cfn):\n        \"\"\"\n            Search for values in all parts of the templates that match the searchRegex\n        \"\"\"\n        results = []\n        results.extend(self._match_values(searchRegex, cfn.template, []))\n        # Globals are removed during a transform.  They need to be checked manually\n        results.extend(self._match_values(searchRegex, cfn.template.get('Globals', {}), []))\n        return results\n\n    def _api_exceptions(self, value):\n        \"\"\" Key value exceptions \"\"\"\n        parameter_search = re.compile(r'^\\$\\{stageVariables\\..*\\}$')\n        return re.match(parameter_search, value)\n\n    def match(self, cfn):\n        \"\"\"Basic Rule Matching\"\"\"\n\n        matches = []\n\n        # Generic regex to match a string containing at least one ${parameter}\n        parameter_search = re.compile(r'^.*(\\$\\{.*\\}.*(\\$\\{.*\\}.*)*)$')\n\n        # Get a list of paths to every leaf node string containing at least one ${parameter}\n        parameter_string_paths = self.match_values(parameter_search, cfn)\n\n        # We want to search all of the paths to check if each one contains an 'Fn::Sub'\n        for parameter_string_path in parameter_string_paths:\n\n            # Exxclude the special IAM variables\n            variable = parameter_string_path[-1]\n\n            if 'Resource' in parameter_string_path:\n                if variable in self.resource_excludes:\n                    continue\n\n            # Exclude literals (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html)\n            if variable.startswith('${!'):\n                continue\n\n            found_sub = False\n            # Does the path contain an 'Fn::Sub'?\n            for step in parameter_string_path:\n                if step in self.api_excludes:\n                    if self._api_exceptions(parameter_string_path[-1]):\n                        found_sub = True\n                elif step == 'Fn::Sub' or step in self.excludes:\n                    found_sub = True\n\n            # If we didn't find an 'Fn::Sub' it means a string containing a ${parameter} may not be evaluated correctly\n            if not found_sub:\n                # Remove the last item (the variable) to prevent multiple errors on 1 line errors\n                path = parameter_string_path[:-1]\n                message = 'Found an embedded parameter outside of an \"Fn::Sub\" at {}'.format('/'.join(map(str, path)))\n                matches.append(RuleMatch(path, message))\n\n        return matches\n", "path": "src/cfnlint/rules/functions/SubNeeded.py"}]}