Repository: aws-cloudformation/cfn-lint

Issue:
cfn-lint shows `W1020 Fn::Sub isn't needed` on Serverless LayerVersion property LayerName when a Variable is actually present
*cfn-lint version: 0.20.1*

cfn-lint shows `W1020 Fn::Sub isn't needed` on Serverless LayerVersion property LayerName when a Variable is actually present in the layerName String of the intrinsic function Sub

Please provide as much information as possible:

sample resource: 
```yaml
APICommonCodeLayer:
    Type: 'AWS::Serverless::LayerVersion'
    Properties:
      Description: API common libraries
      LayerName: 
        Fn::Sub: 'api-common-code-layer-${Environment}'
      ContentUri: api/common
      CompatibleRuntimes:
        - nodejs8.10
      RetentionPolicy: Retain
```
Where Environment is a Paramater with the following definition:

```yaml
Environment:
    AllowedValues:
      - Dev
      - Qa
      - Staging
      - Mirror
      - Prod
    ConstraintDescription: You must specify a valid EnvironmentValue
    Default: Dev
    Description: Environment for to Deploy to
    Type: String
```
This only seems to affect LayerVersions as other resources proceed to not return the warning when using Fn::Sub in their names, even other AWS::Serverless resources.

Sample Template:
```yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: SampleTemplate
Parameters:
  Environment:
    Type: String
    AllowedValues:
      - Dev
      - Qa
      - Staging
      - Mirror
      - Prod
    ConstraintDescription: You must specify a valid EnvironmentValue
    Default: Dev
    Description: Environment for to Deploy to
Resources:
  APICommonCodeLayer:
    Type: 'AWS::Serverless::LayerVersion'
    Properties:
      Description: API common libraries
      LayerName: 
        Fn::Sub: 'api-common-code-layer-${Environment}'
      ContentUri: api/common
      CompatibleRuntimes:
        - nodejs8.10
      RetentionPolicy: Retain
```



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -75,7 +75,7 @@ def get_version(filename):
     install_requires=[
         'pyyaml',
         'six~=1.11',
-        'requests>=2.15.0',
+        'requests>=2.15.0,<=2.21.0',
         'aws-sam-translator>=1.10.0',
         'jsonpatch',
         'jsonschema~=2.6',
diff --git a/src/cfnlint/rules/functions/SubUnneeded.py b/src/cfnlint/rules/functions/SubUnneeded.py
--- a/src/cfnlint/rules/functions/SubUnneeded.py
+++ b/src/cfnlint/rules/functions/SubUnneeded.py
@@ -45,7 +45,7 @@ def match(self, cfn):
 
         matches = []
 
-        sub_objs = cfn.search_deep_keys('Fn::Sub')
+        sub_objs = cfn.transform_pre.get('Fn::Sub')
 
         for sub_obj in sub_objs:
             sub_value_obj = sub_obj[-1]


Test patch:
diff --git a/test/fixtures/templates/good/functions/sub_needed_transform.yaml b/test/fixtures/templates/good/functions/sub_needed_transform.yaml
new file mode 100644
--- /dev/null
+++ b/test/fixtures/templates/good/functions/sub_needed_transform.yaml
@@ -0,0 +1,26 @@
+AWSTemplateFormatVersion: '2010-09-09'
+Transform: 'AWS::Serverless-2016-10-31'
+Description: SampleTemplate
+Parameters:
+  Environment:
+    Type: String
+    AllowedValues:
+      - Dev
+      - Qa
+      - Staging
+      - Mirror
+      - Prod
+    ConstraintDescription: You must specify a valid EnvironmentValue
+    Default: Dev
+    Description: Environment for to Deploy to
+Resources:
+  APICommonCodeLayer:
+    Type: 'AWS::Serverless::LayerVersion'
+    Properties:
+      Description: API common libraries
+      LayerName:
+        Fn::Sub: 'api-common-code-layer-${Environment}'
+      ContentUri: api/common
+      CompatibleRuntimes:
+        - nodejs8.10
+      RetentionPolicy: Retain
diff --git a/test/rules/functions/test_sub_needed.py b/test/rules/functions/test_sub_needed.py
--- a/test/rules/functions/test_sub_needed.py
+++ b/test/rules/functions/test_sub_needed.py
@@ -27,6 +27,7 @@ def setUp(self):
         self.success_templates = [
             'test/fixtures/templates/good/functions/sub.yaml',
             'test/fixtures/templates/good/functions/sub_needed.yaml',
+            'test/fixtures/templates/good/functions/sub_needed_transform.yaml',
         ]
 
     def test_file_positive(self):