We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Invalid PrimaryKey attribute crashes cfn-lint  instead of raising lint error.
Hi AWS,

I found a minor bug on cfn-lint version: cfn-lint 0.8.3

An attribute in Resource -> Properties-> PrimaryKey leads to crash instead of a raised lint error

Here is a sample template. If  MyInvalidAttr is replaced with a correct attribute eg Name then the template works.
```AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
  sam-app

  Sample SAM Template for sam-app

Globals:
  Function:
    Timeout: 3

Resources:
  MyTable:
    Type: AWS::Serverless::SimpleTable
    Properties:
      TableName: MyTable
      PrimaryKey:
        MyInvalidAttr: id
        Type: String
```
Below is the error:
```
$ cfn-lint -t template.yaml
Traceback (most recent call last):
  File "/Users/emilbryggare/Library/Python/2.7/bin/cfn-lint", line 11, in <module>
    sys.exit(main())
  File "/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/__main__.py", line 36, in main
    args.regions, args.override_spec))
  File "/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/core.py", line 46, in run_cli
    return run_checks(filename, template, rules, regions)
  File "/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/core.py", line 316, in run_checks
    matches.extend(runner.transform())
  File "/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/__init__.py", line 894, in transform
    matches = transform.transform_template()
  File "/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/transform.py", line 115, in transform_template
    sam_translator.translate(sam_template=self._template, parameter_values={}))
  File "/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/samtranslator/translator/translator.py", line 72, in translate
    translated = macro.to_cloudformation(**kwargs)
  File "/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/samtranslator/model/sam_resources.py", line 537, in to_cloudformation
    dynamodb_resources = self._construct_dynamodb_table()
  File "/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/samtranslator/model/sam_resources.py", line 546, in _construct_dynamodb_table
    'AttributeName': self.PrimaryKey['Name'],
KeyError: 'Name'
```


--- 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/transform.py`
Content:
```
1 """
2   Copyright 2018 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 os
18 import six
19 
20 from samtranslator.parser import parser
21 from samtranslator.translator.translator import Translator
22 from samtranslator.public.exceptions import InvalidDocumentException
23 
24 import cfnlint.helpers
25 
26 
27 class Transform(object):
28     """
29     Application Serverless Module tranform Wrappor. Based on code from AWS SAM CLI:
30     https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/commands/validate/lib/sam_template_validator.py
31     """
32 
33     def __init__(self, filename, template, region):
34         """
35         Initialize Transform class
36         """
37         self._filename = filename
38         self._template = template
39         self._region = region
40 
41         self._managed_policy_map = self.load_managed_policies()
42         self._sam_parser = parser.Parser()
43 
44     def template(self):
45         """Get the template"""
46         return self._template
47 
48     def load_managed_policies(self):
49         """
50         Load the ManagedPolicies locally, based on the AWS-CLI:
51         https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/lib/samlib/default_managed_policies.json
52         """
53         return cfnlint.helpers.load_resources('data/Serverless/ManagedPolicies.json')
54 
55     def _replace_local_codeuri(self):
56         """
57         Replaces the CodeUri in AWS::Serverless::Function and DefinitionUri in AWS::Serverless::Api to a fake
58         S3 Uri. This is to support running the SAM Translator with valid values for these fields. If this in not done,
59         the template is invalid in the eyes of SAM Translator (the translator does not support local paths)
60         """
61 
62         all_resources = self._template.get('Resources', {})
63 
64         for _, resource in all_resources.items():
65 
66             resource_type = resource.get('Type')
67             resource_dict = resource.get('Properties')
68 
69             if resource_type == 'AWS::Serverless::Function':
70 
71                 Transform._update_to_s3_uri('CodeUri', resource_dict)
72 
73             if resource_type == 'AWS::Serverless::Api':
74                 if 'DefinitionBody' not in resource_dict:
75                     Transform._update_to_s3_uri('DefinitionUri', resource_dict)
76 
77     def transform_template(self):
78         """
79         Transform the Template using the Serverless Application Model.
80         """
81         matches = []
82 
83         try:
84             sam_translator = Translator(managed_policy_map=self._managed_policy_map,
85                                         sam_parser=self._sam_parser)
86 
87             self._replace_local_codeuri()
88 
89             # Tell SAM to use the region we're linting in, this has to be controlled using the default AWS mechanisms, see also:
90             # https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/translator/arn_generator.py
91             os.environ['AWS_DEFAULT_REGION'] = self._region
92 
93             # In the Paser class, within the SAM Translator, they log a warning for when the template
94             # does not match the schema. The logger they use is the root logger instead of one scoped to
95             # their module. Currently this does not cause templates to fail, so we will suppress this
96             # by patching the logging.warning method that is used in that class.
97             class WarningSuppressLogger(object):
98                 """ Patch the Logger in SAM """
99 
100                 def __init__(self, obj_to_patch):
101                     self.obj_to_patch = obj_to_patch
102 
103                 def __enter__(self):
104                     self.obj_to_patch.warning = self.warning
105 
106                 def __exit__(self, exc_type, exc_val, exc_tb):
107                     self.obj_to_patch.warning = self.obj_to_patch.warning
108 
109                 def warning(self, message):
110                     """ Ignore warnings from SAM """
111                     pass
112 
113             with WarningSuppressLogger(parser.logging):
114                 self._template = cfnlint.helpers.convert_dict(
115                     sam_translator.translate(sam_template=self._template, parameter_values={}))
116         except InvalidDocumentException as e:
117             for cause in e.causes:
118                 matches.append(cfnlint.Match(
119                     1, 1,
120                     1, 1,
121                     self._filename, cfnlint.TransformError(), cause.message))
122 
123         return matches
124 
125     @staticmethod
126     def is_s3_uri(uri):
127         """
128         Checks the uri and determines if it is a valid S3 Uri
129         Parameters
130         ----------
131         uri str, required
132             Uri to check
133         Returns
134         -------
135         bool
136             Returns True if the uri given is an S3 uri, otherwise False
137         """
138         return isinstance(uri, six.string_types) and uri.startswith('s3://')
139 
140     @staticmethod
141     def _update_to_s3_uri(property_key, resource_property_dict, s3_uri_value='s3://bucket/value'):
142         """
143         Updates the 'property_key' in the 'resource_property_dict' to the value of 's3_uri_value'
144         Note: The function will mutate the resource_property_dict that is pass in
145         Parameters
146         ----------
147         property_key str, required
148             Key in the resource_property_dict
149         resource_property_dict dict, required
150             Property dictionary of a Resource in the template to replace
151         s3_uri_value str, optional
152             Value to update the value of the property_key to
153         """
154         uri_property = resource_property_dict.get(property_key, '.')
155 
156         # ignore if dict or already an S3 Uri
157         if isinstance(uri_property, dict) or Transform.is_s3_uri(uri_property):
158             return
159 
160         resource_property_dict[property_key] = s3_uri_value
161
```
--- 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/transform.py b/src/cfnlint/transform.py
--- a/src/cfnlint/transform.py
+++ b/src/cfnlint/transform.py
@@ -15,14 +15,14 @@
   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 """
 import os
+import logging
 import six
-
 from samtranslator.parser import parser
 from samtranslator.translator.translator import Translator
 from samtranslator.public.exceptions import InvalidDocumentException
 
 import cfnlint.helpers
-
+LOGGER = logging.getLogger('cfnlint')
 
 class Transform(object):
     """
@@ -119,6 +119,14 @@
                     1, 1,
                     1, 1,
                     self._filename, cfnlint.TransformError(), cause.message))
+        except Exception as e:  # pylint: disable=W0703
+            LOGGER.debug('Error transforming template: %s', str(e))
+            LOGGER.debug('Stack trace: %s', e, exc_info=True)
+            message = 'Error transforming template: {0}'
+            matches.append(cfnlint.Match(
+                1, 1,
+                1, 1,
+                self._filename, cfnlint.TransformError(), message.format(str(e))))
 
         return matches

{"golden_diff": "diff --git a/src/cfnlint/transform.py b/src/cfnlint/transform.py\n--- a/src/cfnlint/transform.py\n+++ b/src/cfnlint/transform.py\n@@ -15,14 +15,14 @@\n   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n \"\"\"\n import os\n+import logging\n import six\n-\n from samtranslator.parser import parser\n from samtranslator.translator.translator import Translator\n from samtranslator.public.exceptions import InvalidDocumentException\n \n import cfnlint.helpers\n-\n+LOGGER = logging.getLogger('cfnlint')\n \n class Transform(object):\n     \"\"\"\n@@ -119,6 +119,14 @@\n                     1, 1,\n                     1, 1,\n                     self._filename, cfnlint.TransformError(), cause.message))\n+        except Exception as e:  # pylint: disable=W0703\n+            LOGGER.debug('Error transforming template: %s', str(e))\n+            LOGGER.debug('Stack trace: %s', e, exc_info=True)\n+            message = 'Error transforming template: {0}'\n+            matches.append(cfnlint.Match(\n+                1, 1,\n+                1, 1,\n+                self._filename, cfnlint.TransformError(), message.format(str(e))))\n \n         return matches\n", "issue": "Invalid PrimaryKey attribute crashes cfn-lint  instead of raising lint error.\nHi AWS,\r\n\r\nI found a minor bug on cfn-lint version: cfn-lint 0.8.3\r\n\r\nAn attribute in Resource -> Properties-> PrimaryKey leads to crash instead of a raised lint error\r\n\r\nHere is a sample template. If  MyInvalidAttr is replaced with a correct attribute eg Name then the template works.\r\n```AWSTemplateFormatVersion: \"2010-09-09\"\r\nTransform: AWS::Serverless-2016-10-31\r\nDescription: >\r\n  sam-app\r\n\r\n  Sample SAM Template for sam-app\r\n\r\nGlobals:\r\n  Function:\r\n    Timeout: 3\r\n\r\nResources:\r\n  MyTable:\r\n    Type: AWS::Serverless::SimpleTable\r\n    Properties:\r\n      TableName: MyTable\r\n      PrimaryKey:\r\n        MyInvalidAttr: id\r\n        Type: String\r\n```\r\nBelow is the error:\r\n```\r\n$ cfn-lint -t template.yaml\r\nTraceback (most recent call last):\r\n  File \"/Users/emilbryggare/Library/Python/2.7/bin/cfn-lint\", line 11, in <module>\r\n    sys.exit(main())\r\n  File \"/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/__main__.py\", line 36, in main\r\n    args.regions, args.override_spec))\r\n  File \"/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/core.py\", line 46, in run_cli\r\n    return run_checks(filename, template, rules, regions)\r\n  File \"/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/core.py\", line 316, in run_checks\r\n    matches.extend(runner.transform())\r\n  File \"/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/__init__.py\", line 894, in transform\r\n    matches = transform.transform_template()\r\n  File \"/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/cfnlint/transform.py\", line 115, in transform_template\r\n    sam_translator.translate(sam_template=self._template, parameter_values={}))\r\n  File \"/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/samtranslator/translator/translator.py\", line 72, in translate\r\n    translated = macro.to_cloudformation(**kwargs)\r\n  File \"/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/samtranslator/model/sam_resources.py\", line 537, in to_cloudformation\r\n    dynamodb_resources = self._construct_dynamodb_table()\r\n  File \"/Users/emilbryggare/Library/Python/2.7/lib/python/site-packages/samtranslator/model/sam_resources.py\", line 546, in _construct_dynamodb_table\r\n    'AttributeName': self.PrimaryKey['Name'],\r\nKeyError: 'Name'\r\n```\r\n\n", "before_files": [{"content": "\"\"\"\n  Copyright 2018 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 os\nimport six\n\nfrom samtranslator.parser import parser\nfrom samtranslator.translator.translator import Translator\nfrom samtranslator.public.exceptions import InvalidDocumentException\n\nimport cfnlint.helpers\n\n\nclass Transform(object):\n    \"\"\"\n    Application Serverless Module tranform Wrappor. Based on code from AWS SAM CLI:\n    https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/commands/validate/lib/sam_template_validator.py\n    \"\"\"\n\n    def __init__(self, filename, template, region):\n        \"\"\"\n        Initialize Transform class\n        \"\"\"\n        self._filename = filename\n        self._template = template\n        self._region = region\n\n        self._managed_policy_map = self.load_managed_policies()\n        self._sam_parser = parser.Parser()\n\n    def template(self):\n        \"\"\"Get the template\"\"\"\n        return self._template\n\n    def load_managed_policies(self):\n        \"\"\"\n        Load the ManagedPolicies locally, based on the AWS-CLI:\n        https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/lib/samlib/default_managed_policies.json\n        \"\"\"\n        return cfnlint.helpers.load_resources('data/Serverless/ManagedPolicies.json')\n\n    def _replace_local_codeuri(self):\n        \"\"\"\n        Replaces the CodeUri in AWS::Serverless::Function and DefinitionUri in AWS::Serverless::Api to a fake\n        S3 Uri. This is to support running the SAM Translator with valid values for these fields. If this in not done,\n        the template is invalid in the eyes of SAM Translator (the translator does not support local paths)\n        \"\"\"\n\n        all_resources = self._template.get('Resources', {})\n\n        for _, resource in all_resources.items():\n\n            resource_type = resource.get('Type')\n            resource_dict = resource.get('Properties')\n\n            if resource_type == 'AWS::Serverless::Function':\n\n                Transform._update_to_s3_uri('CodeUri', resource_dict)\n\n            if resource_type == 'AWS::Serverless::Api':\n                if 'DefinitionBody' not in resource_dict:\n                    Transform._update_to_s3_uri('DefinitionUri', resource_dict)\n\n    def transform_template(self):\n        \"\"\"\n        Transform the Template using the Serverless Application Model.\n        \"\"\"\n        matches = []\n\n        try:\n            sam_translator = Translator(managed_policy_map=self._managed_policy_map,\n                                        sam_parser=self._sam_parser)\n\n            self._replace_local_codeuri()\n\n            # Tell SAM to use the region we're linting in, this has to be controlled using the default AWS mechanisms, see also:\n            # https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/translator/arn_generator.py\n            os.environ['AWS_DEFAULT_REGION'] = self._region\n\n            # In the Paser class, within the SAM Translator, they log a warning for when the template\n            # does not match the schema. The logger they use is the root logger instead of one scoped to\n            # their module. Currently this does not cause templates to fail, so we will suppress this\n            # by patching the logging.warning method that is used in that class.\n            class WarningSuppressLogger(object):\n                \"\"\" Patch the Logger in SAM \"\"\"\n\n                def __init__(self, obj_to_patch):\n                    self.obj_to_patch = obj_to_patch\n\n                def __enter__(self):\n                    self.obj_to_patch.warning = self.warning\n\n                def __exit__(self, exc_type, exc_val, exc_tb):\n                    self.obj_to_patch.warning = self.obj_to_patch.warning\n\n                def warning(self, message):\n                    \"\"\" Ignore warnings from SAM \"\"\"\n                    pass\n\n            with WarningSuppressLogger(parser.logging):\n                self._template = cfnlint.helpers.convert_dict(\n                    sam_translator.translate(sam_template=self._template, parameter_values={}))\n        except InvalidDocumentException as e:\n            for cause in e.causes:\n                matches.append(cfnlint.Match(\n                    1, 1,\n                    1, 1,\n                    self._filename, cfnlint.TransformError(), cause.message))\n\n        return matches\n\n    @staticmethod\n    def is_s3_uri(uri):\n        \"\"\"\n        Checks the uri and determines if it is a valid S3 Uri\n        Parameters\n        ----------\n        uri str, required\n            Uri to check\n        Returns\n        -------\n        bool\n            Returns True if the uri given is an S3 uri, otherwise False\n        \"\"\"\n        return isinstance(uri, six.string_types) and uri.startswith('s3://')\n\n    @staticmethod\n    def _update_to_s3_uri(property_key, resource_property_dict, s3_uri_value='s3://bucket/value'):\n        \"\"\"\n        Updates the 'property_key' in the 'resource_property_dict' to the value of 's3_uri_value'\n        Note: The function will mutate the resource_property_dict that is pass in\n        Parameters\n        ----------\n        property_key str, required\n            Key in the resource_property_dict\n        resource_property_dict dict, required\n            Property dictionary of a Resource in the template to replace\n        s3_uri_value str, optional\n            Value to update the value of the property_key to\n        \"\"\"\n        uri_property = resource_property_dict.get(property_key, '.')\n\n        # ignore if dict or already an S3 Uri\n        if isinstance(uri_property, dict) or Transform.is_s3_uri(uri_property):\n            return\n\n        resource_property_dict[property_key] = s3_uri_value\n", "path": "src/cfnlint/transform.py"}], "after_files": [{"content": "\"\"\"\n  Copyright 2018 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 os\nimport logging\nimport six\nfrom samtranslator.parser import parser\nfrom samtranslator.translator.translator import Translator\nfrom samtranslator.public.exceptions import InvalidDocumentException\n\nimport cfnlint.helpers\nLOGGER = logging.getLogger('cfnlint')\n\nclass Transform(object):\n    \"\"\"\n    Application Serverless Module tranform Wrappor. Based on code from AWS SAM CLI:\n    https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/commands/validate/lib/sam_template_validator.py\n    \"\"\"\n\n    def __init__(self, filename, template, region):\n        \"\"\"\n        Initialize Transform class\n        \"\"\"\n        self._filename = filename\n        self._template = template\n        self._region = region\n\n        self._managed_policy_map = self.load_managed_policies()\n        self._sam_parser = parser.Parser()\n\n    def template(self):\n        \"\"\"Get the template\"\"\"\n        return self._template\n\n    def load_managed_policies(self):\n        \"\"\"\n        Load the ManagedPolicies locally, based on the AWS-CLI:\n        https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/lib/samlib/default_managed_policies.json\n        \"\"\"\n        return cfnlint.helpers.load_resources('data/Serverless/ManagedPolicies.json')\n\n    def _replace_local_codeuri(self):\n        \"\"\"\n        Replaces the CodeUri in AWS::Serverless::Function and DefinitionUri in AWS::Serverless::Api to a fake\n        S3 Uri. This is to support running the SAM Translator with valid values for these fields. If this in not done,\n        the template is invalid in the eyes of SAM Translator (the translator does not support local paths)\n        \"\"\"\n\n        all_resources = self._template.get('Resources', {})\n\n        for _, resource in all_resources.items():\n\n            resource_type = resource.get('Type')\n            resource_dict = resource.get('Properties')\n\n            if resource_type == 'AWS::Serverless::Function':\n\n                Transform._update_to_s3_uri('CodeUri', resource_dict)\n\n            if resource_type == 'AWS::Serverless::Api':\n                if 'DefinitionBody' not in resource_dict:\n                    Transform._update_to_s3_uri('DefinitionUri', resource_dict)\n\n    def transform_template(self):\n        \"\"\"\n        Transform the Template using the Serverless Application Model.\n        \"\"\"\n        matches = []\n\n        try:\n            sam_translator = Translator(managed_policy_map=self._managed_policy_map,\n                                        sam_parser=self._sam_parser)\n\n            self._replace_local_codeuri()\n\n            # Tell SAM to use the region we're linting in, this has to be controlled using the default AWS mechanisms, see also:\n            # https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/translator/arn_generator.py\n            os.environ['AWS_DEFAULT_REGION'] = self._region\n\n            # In the Paser class, within the SAM Translator, they log a warning for when the template\n            # does not match the schema. The logger they use is the root logger instead of one scoped to\n            # their module. Currently this does not cause templates to fail, so we will suppress this\n            # by patching the logging.warning method that is used in that class.\n            class WarningSuppressLogger(object):\n                \"\"\" Patch the Logger in SAM \"\"\"\n\n                def __init__(self, obj_to_patch):\n                    self.obj_to_patch = obj_to_patch\n\n                def __enter__(self):\n                    self.obj_to_patch.warning = self.warning\n\n                def __exit__(self, exc_type, exc_val, exc_tb):\n                    self.obj_to_patch.warning = self.obj_to_patch.warning\n\n                def warning(self, message):\n                    \"\"\" Ignore warnings from SAM \"\"\"\n                    pass\n\n            with WarningSuppressLogger(parser.logging):\n                self._template = cfnlint.helpers.convert_dict(\n                    sam_translator.translate(sam_template=self._template, parameter_values={}))\n        except InvalidDocumentException as e:\n            for cause in e.causes:\n                matches.append(cfnlint.Match(\n                    1, 1,\n                    1, 1,\n                    self._filename, cfnlint.TransformError(), cause.message))\n        except Exception as e:  # pylint: disable=W0703\n            LOGGER.debug('Error transforming template: %s', str(e))\n            LOGGER.debug('Stack trace: %s', e, exc_info=True)\n            message = 'Error transforming template: {0}'\n            matches.append(cfnlint.Match(\n                1, 1,\n                1, 1,\n                self._filename, cfnlint.TransformError(), message.format(str(e))))\n\n        return matches\n\n    @staticmethod\n    def is_s3_uri(uri):\n        \"\"\"\n        Checks the uri and determines if it is a valid S3 Uri\n        Parameters\n        ----------\n        uri str, required\n            Uri to check\n        Returns\n        -------\n        bool\n            Returns True if the uri given is an S3 uri, otherwise False\n        \"\"\"\n        return isinstance(uri, six.string_types) and uri.startswith('s3://')\n\n    @staticmethod\n    def _update_to_s3_uri(property_key, resource_property_dict, s3_uri_value='s3://bucket/value'):\n        \"\"\"\n        Updates the 'property_key' in the 'resource_property_dict' to the value of 's3_uri_value'\n        Note: The function will mutate the resource_property_dict that is pass in\n        Parameters\n        ----------\n        property_key str, required\n            Key in the resource_property_dict\n        resource_property_dict dict, required\n            Property dictionary of a Resource in the template to replace\n        s3_uri_value str, optional\n            Value to update the value of the property_key to\n        \"\"\"\n        uri_property = resource_property_dict.get(property_key, '.')\n\n        # ignore if dict or already an S3 Uri\n        if isinstance(uri_property, dict) or Transform.is_s3_uri(uri_property):\n            return\n\n        resource_property_dict[property_key] = s3_uri_value\n", "path": "src/cfnlint/transform.py"}]}