We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
E0001: Error DisableExecuteApiEndpoint works only within 'DefinitionBody' property
### CloudFormation Lint Version

0.73.1

### What operating system are you using?

Ubuntu

### Describe the bug

I want to disable the execute api endpoint in my RestAPI using SAM. This works as expected in deployment by adding the ` DisableExecuteApiEndpoint: True` property on `Properties` for a `AWS::Serverless::Api` type (see reproduction template). 

However cfn-lint gives this error message running:

```
$ cfn-lint -t template.yaml

E0001 Error transforming template: Resource with id [ApiGatewayRestApi] is invalid. DisableExecuteApiEndpoint works only within 'DefinitionBody' property.
template2.yaml:1:1
```

### Expected behavior

No E0001 lint error when using DisableExecuteApiEndpoint on a SAM `AWS::Serverless::Api`

### Reproduction template

```yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Resources:
  ApiGatewayRestApi:
    Type: AWS::Serverless::Api
    Properties:
      OpenApiVersion: "3.0.3"
      DisableExecuteApiEndpoint: True
      StageName: default
      EndpointConfiguration:
        Type: REGIONAL

  Function:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs16.x
      InlineCode: |
        exports.handler = async (event) => ++event;
      Events:
        Notify:
          Type: Api
          Properties:
            Method: POST
            Path: /
            RestApiId: !Ref ApiGatewayRestApi
```

--- 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 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 SPDX-License-Identifier: MIT-0
4 """
5 import logging
6 import os
7 
8 import samtranslator
9 from samtranslator.parser import parser
10 from samtranslator.public.exceptions import InvalidDocumentException
11 from samtranslator.sdk import resource
12 from samtranslator.translator.translator import Translator
13 
14 from cfnlint.data import Serverless
15 from cfnlint.helpers import convert_dict, format_json_string, load_resource
16 from cfnlint.rules import Match, TransformError
17 
18 LOGGER = logging.getLogger("cfnlint")
19 
20 samtranslator_logger = logging.getLogger("samtranslator")
21 samtranslator_logger.setLevel(logging.CRITICAL)
22 
23 
24 # Override SAM validation as cfn-lint does thoese
25 # checks already
26 # pylint: disable=unused-argument
27 def valid_override(self):
28     return resource.SamResourceType.has_value(self.type)
29 
30 
31 # pylint: disable=redefined-outer-name
32 resource.SamResource.valid = valid_override
33 
34 
35 class Transform:
36     """
37     Application Serverless Module tranform Wrapper.
38     Based on code from AWS SAM CLI:
39     https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/commands/validate/lib/sam_template_validator.py
40     """
41 
42     def __init__(self, filename, template, region):
43         """
44         Initialize Transform class
45         """
46         self._filename = filename
47         self._template = template
48         self._region = region
49         self._parameters = {}
50 
51         self._managed_policy_map = self.load_managed_policies()
52         self._sam_parser = parser.Parser()
53 
54     def template(self):
55         """Get the template"""
56         return self._template
57 
58     def load_managed_policies(self):
59         """
60         Load the ManagedPolicies locally, based on the AWS-CLI:
61         https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/lib/samlib/default_managed_policies.json
62         """
63         return load_resource(Serverless, "ManagedPolicies.json")
64 
65     def _replace_local_codeuri(self):
66         """
67         Replaces the CodeUri in AWS::Serverless::Function and DefinitionUri in
68         AWS::Serverless::Api to a fake S3 Uri. This is to support running the
69         SAM Translator with valid values for these fields. If this is not done,
70         the template is invalid in the eyes of SAM Translator (the translator
71         does not support local paths)
72         """
73 
74         all_resources = self._template.get("Resources", {})
75 
76         template_globals = self._template.get("Globals", {})
77         auto_publish_alias = template_globals.get("Function", {}).get(
78             "AutoPublishAlias"
79         )
80         if isinstance(auto_publish_alias, dict):
81             if len(auto_publish_alias) == 1:
82                 for k, v in auto_publish_alias.items():
83                     if k == "Ref":
84                         if v in self._template.get("Parameters"):
85                             self._parameters[v] = "Alias"
86 
87         for _, resource in all_resources.items():
88             resource_type = resource.get("Type")
89             resource_dict = resource.get("Properties")
90 
91             if resource_type == "AWS::Serverless::Function":
92                 if resource_dict.get("PackageType") == "Image":
93                     Transform._update_to_s3_uri("ImageUri", resource_dict)
94                 else:
95                     Transform._update_to_s3_uri("CodeUri", resource_dict)
96                 auto_publish_alias = resource_dict.get("AutoPublishAlias")
97                 if isinstance(auto_publish_alias, dict):
98                     if len(auto_publish_alias) == 1:
99                         for k, v in auto_publish_alias.items():
100                             if k == "Ref":
101                                 if v in self._template.get("Parameters"):
102                                     self._parameters[v] = "Alias"
103             if resource_type in ["AWS::Serverless::LayerVersion"]:
104                 if resource_dict.get("ContentUri"):
105                     Transform._update_to_s3_uri("ContentUri", resource_dict)
106             if resource_type == "AWS::Serverless::Application":
107                 if resource_dict.get("Location"):
108                     if isinstance(resource_dict.get("Location"), dict):
109                         resource_dict["Location"] = ""
110                         Transform._update_to_s3_uri("Location", resource_dict)
111             if resource_type == "AWS::Serverless::Api":
112                 if (
113                     "DefinitionBody" not in resource_dict
114                     and "Auth" not in resource_dict
115                     and "Cors" not in resource_dict
116                 ):
117                     Transform._update_to_s3_uri("DefinitionUri", resource_dict)
118                 else:
119                     resource_dict["DefinitionBody"] = ""
120             if resource_type == "AWS::Serverless::StateMachine" and resource_dict.get(
121                 "DefinitionUri"
122             ):
123                 Transform._update_to_s3_uri("DefinitionUri", resource_dict)
124 
125     def transform_template(self):
126         """
127         Transform the Template using the Serverless Application Model.
128         """
129         matches = []
130 
131         try:
132             # Output the SAM Translator version in debug mode
133             LOGGER.info("SAM Translator: %s", samtranslator.__version__)
134 
135             sam_translator = Translator(
136                 managed_policy_map=self._managed_policy_map, sam_parser=self._sam_parser
137             )
138 
139             self._replace_local_codeuri()
140 
141             # Tell SAM to use the region we're linting in, this has to be
142             # controlled using the default AWS mechanisms, see also:
143             # https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/translator/arn_generator.py
144             LOGGER.info("Setting AWS_DEFAULT_REGION to %s", self._region)
145             os.environ["AWS_DEFAULT_REGION"] = self._region
146 
147             self._template = convert_dict(
148                 sam_translator.translate(
149                     sam_template=self._template, parameter_values=self._parameters
150                 )
151             )
152 
153             LOGGER.info(
154                 "Transformed template: \n%s", format_json_string(self._template)
155             )
156         except InvalidDocumentException as e:
157             message = "Error transforming template: {0}"
158             for cause in e.causes:
159                 matches.append(
160                     Match(
161                         1,
162                         1,
163                         1,
164                         1,
165                         self._filename,
166                         TransformError(),
167                         message.format(cause.message),
168                     )
169                 )
170         except Exception as e:  # pylint: disable=W0703
171             LOGGER.debug("Error transforming template: %s", str(e))
172             LOGGER.debug("Stack trace: %s", e, exc_info=True)
173             message = "Error transforming template: {0}"
174             matches.append(
175                 Match(
176                     1, 1, 1, 1, self._filename, TransformError(), message.format(str(e))
177                 )
178             )
179 
180         return matches
181 
182     @staticmethod
183     def is_s3_uri(uri):
184         """
185         Checks the uri and determines if it is a valid S3 Uri
186         Parameters
187         ----------
188         uri str, required
189             Uri to check
190         Returns
191         -------
192         bool
193             Returns True if the uri given is an S3 uri, otherwise False
194         """
195         return isinstance(uri, str) and uri.startswith("s3://")
196 
197     @staticmethod
198     def _update_to_s3_uri(
199         property_key, resource_property_dict, s3_uri_value="s3://bucket/value"
200     ):
201         """
202         Updates the 'property_key' in the 'resource_property_dict' to the
203         value of 's3_uri_value'
204         Note: The function will mutate the resource_property_dict that is pass
205         in Parameters
206         ----------
207         property_key str, required
208             Key in the resource_property_dict
209         resource_property_dict dict, required
210             Property dictionary of a Resource in the template to replace
211         s3_uri_value str, optional
212             Value to update the value of the property_key to
213         """
214         uri_property = resource_property_dict.get(property_key, ".")
215 
216         # ignore if dict or already an S3 Uri
217         if isinstance(uri_property, dict):
218             if len(uri_property) == 1:
219                 for k in uri_property.keys():
220                     if k == "Ref":
221                         resource_property_dict[property_key] = s3_uri_value
222             return
223         if Transform.is_s3_uri(uri_property):
224             return
225 
226         resource_property_dict[property_key] = s3_uri_value
227
```
--- 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
@@ -113,6 +113,7 @@
                     "DefinitionBody" not in resource_dict
                     and "Auth" not in resource_dict
                     and "Cors" not in resource_dict
+                    and "DisableExecuteApiEndpoint" not in resource_dict
                 ):
                     Transform._update_to_s3_uri("DefinitionUri", resource_dict)
                 else:

{"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@@ -113,6 +113,7 @@\n                     \"DefinitionBody\" not in resource_dict\n                     and \"Auth\" not in resource_dict\n                     and \"Cors\" not in resource_dict\n+                    and \"DisableExecuteApiEndpoint\" not in resource_dict\n                 ):\n                     Transform._update_to_s3_uri(\"DefinitionUri\", resource_dict)\n                 else:\n", "issue": "E0001: Error DisableExecuteApiEndpoint works only within 'DefinitionBody' property\n### CloudFormation Lint Version\n\n0.73.1\n\n### What operating system are you using?\n\nUbuntu\n\n### Describe the bug\n\nI want to disable the execute api endpoint in my RestAPI using SAM. This works as expected in deployment by adding the ` DisableExecuteApiEndpoint: True` property on `Properties` for a `AWS::Serverless::Api` type (see reproduction template). \r\n\r\nHowever cfn-lint gives this error message running:\r\n\r\n```\r\n$ cfn-lint -t template.yaml\r\n\r\nE0001 Error transforming template: Resource with id [ApiGatewayRestApi] is invalid. DisableExecuteApiEndpoint works only within 'DefinitionBody' property.\r\ntemplate2.yaml:1:1\r\n```\n\n### Expected behavior\n\nNo E0001 lint error when using DisableExecuteApiEndpoint on a SAM `AWS::Serverless::Api`\n\n### Reproduction template\n\n```yaml\r\nAWSTemplateFormatVersion: '2010-09-09'\r\nTransform: AWS::Serverless-2016-10-31\r\n\r\nResources:\r\n  ApiGatewayRestApi:\r\n    Type: AWS::Serverless::Api\r\n    Properties:\r\n      OpenApiVersion: \"3.0.3\"\r\n      DisableExecuteApiEndpoint: True\r\n      StageName: default\r\n      EndpointConfiguration:\r\n        Type: REGIONAL\r\n\r\n  Function:\r\n    Type: AWS::Serverless::Function\r\n    Properties:\r\n      Handler: index.handler\r\n      Runtime: nodejs16.x\r\n      InlineCode: |\r\n        exports.handler = async (event) => ++event;\r\n      Events:\r\n        Notify:\r\n          Type: Api\r\n          Properties:\r\n            Method: POST\r\n            Path: /\r\n            RestApiId: !Ref ApiGatewayRestApi\r\n```\n", "before_files": [{"content": "\"\"\"\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0\n\"\"\"\nimport logging\nimport os\n\nimport samtranslator\nfrom samtranslator.parser import parser\nfrom samtranslator.public.exceptions import InvalidDocumentException\nfrom samtranslator.sdk import resource\nfrom samtranslator.translator.translator import Translator\n\nfrom cfnlint.data import Serverless\nfrom cfnlint.helpers import convert_dict, format_json_string, load_resource\nfrom cfnlint.rules import Match, TransformError\n\nLOGGER = logging.getLogger(\"cfnlint\")\n\nsamtranslator_logger = logging.getLogger(\"samtranslator\")\nsamtranslator_logger.setLevel(logging.CRITICAL)\n\n\n# Override SAM validation as cfn-lint does thoese\n# checks already\n# pylint: disable=unused-argument\ndef valid_override(self):\n    return resource.SamResourceType.has_value(self.type)\n\n\n# pylint: disable=redefined-outer-name\nresource.SamResource.valid = valid_override\n\n\nclass Transform:\n    \"\"\"\n    Application Serverless Module tranform Wrapper.\n    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        self._parameters = {}\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 load_resource(Serverless, \"ManagedPolicies.json\")\n\n    def _replace_local_codeuri(self):\n        \"\"\"\n        Replaces the CodeUri in AWS::Serverless::Function and DefinitionUri in\n        AWS::Serverless::Api to a fake S3 Uri. This is to support running the\n        SAM Translator with valid values for these fields. If this is not done,\n        the template is invalid in the eyes of SAM Translator (the translator\n        does not support local paths)\n        \"\"\"\n\n        all_resources = self._template.get(\"Resources\", {})\n\n        template_globals = self._template.get(\"Globals\", {})\n        auto_publish_alias = template_globals.get(\"Function\", {}).get(\n            \"AutoPublishAlias\"\n        )\n        if isinstance(auto_publish_alias, dict):\n            if len(auto_publish_alias) == 1:\n                for k, v in auto_publish_alias.items():\n                    if k == \"Ref\":\n                        if v in self._template.get(\"Parameters\"):\n                            self._parameters[v] = \"Alias\"\n\n        for _, resource in all_resources.items():\n            resource_type = resource.get(\"Type\")\n            resource_dict = resource.get(\"Properties\")\n\n            if resource_type == \"AWS::Serverless::Function\":\n                if resource_dict.get(\"PackageType\") == \"Image\":\n                    Transform._update_to_s3_uri(\"ImageUri\", resource_dict)\n                else:\n                    Transform._update_to_s3_uri(\"CodeUri\", resource_dict)\n                auto_publish_alias = resource_dict.get(\"AutoPublishAlias\")\n                if isinstance(auto_publish_alias, dict):\n                    if len(auto_publish_alias) == 1:\n                        for k, v in auto_publish_alias.items():\n                            if k == \"Ref\":\n                                if v in self._template.get(\"Parameters\"):\n                                    self._parameters[v] = \"Alias\"\n            if resource_type in [\"AWS::Serverless::LayerVersion\"]:\n                if resource_dict.get(\"ContentUri\"):\n                    Transform._update_to_s3_uri(\"ContentUri\", resource_dict)\n            if resource_type == \"AWS::Serverless::Application\":\n                if resource_dict.get(\"Location\"):\n                    if isinstance(resource_dict.get(\"Location\"), dict):\n                        resource_dict[\"Location\"] = \"\"\n                        Transform._update_to_s3_uri(\"Location\", resource_dict)\n            if resource_type == \"AWS::Serverless::Api\":\n                if (\n                    \"DefinitionBody\" not in resource_dict\n                    and \"Auth\" not in resource_dict\n                    and \"Cors\" not in resource_dict\n                ):\n                    Transform._update_to_s3_uri(\"DefinitionUri\", resource_dict)\n                else:\n                    resource_dict[\"DefinitionBody\"] = \"\"\n            if resource_type == \"AWS::Serverless::StateMachine\" and resource_dict.get(\n                \"DefinitionUri\"\n            ):\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            # Output the SAM Translator version in debug mode\n            LOGGER.info(\"SAM Translator: %s\", samtranslator.__version__)\n\n            sam_translator = Translator(\n                managed_policy_map=self._managed_policy_map, sam_parser=self._sam_parser\n            )\n\n            self._replace_local_codeuri()\n\n            # Tell SAM to use the region we're linting in, this has to be\n            # controlled using the default AWS mechanisms, see also:\n            # https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/translator/arn_generator.py\n            LOGGER.info(\"Setting AWS_DEFAULT_REGION to %s\", self._region)\n            os.environ[\"AWS_DEFAULT_REGION\"] = self._region\n\n            self._template = convert_dict(\n                sam_translator.translate(\n                    sam_template=self._template, parameter_values=self._parameters\n                )\n            )\n\n            LOGGER.info(\n                \"Transformed template: \\n%s\", format_json_string(self._template)\n            )\n        except InvalidDocumentException as e:\n            message = \"Error transforming template: {0}\"\n            for cause in e.causes:\n                matches.append(\n                    Match(\n                        1,\n                        1,\n                        1,\n                        1,\n                        self._filename,\n                        TransformError(),\n                        message.format(cause.message),\n                    )\n                )\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(\n                Match(\n                    1, 1, 1, 1, self._filename, TransformError(), message.format(str(e))\n                )\n            )\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, str) and uri.startswith(\"s3://\")\n\n    @staticmethod\n    def _update_to_s3_uri(\n        property_key, resource_property_dict, s3_uri_value=\"s3://bucket/value\"\n    ):\n        \"\"\"\n        Updates the 'property_key' in the 'resource_property_dict' to the\n        value of 's3_uri_value'\n        Note: The function will mutate the resource_property_dict that is pass\n        in 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):\n            if len(uri_property) == 1:\n                for k in uri_property.keys():\n                    if k == \"Ref\":\n                        resource_property_dict[property_key] = s3_uri_value\n            return\n        if 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": "\"\"\"\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0\n\"\"\"\nimport logging\nimport os\n\nimport samtranslator\nfrom samtranslator.parser import parser\nfrom samtranslator.public.exceptions import InvalidDocumentException\nfrom samtranslator.sdk import resource\nfrom samtranslator.translator.translator import Translator\n\nfrom cfnlint.data import Serverless\nfrom cfnlint.helpers import convert_dict, format_json_string, load_resource\nfrom cfnlint.rules import Match, TransformError\n\nLOGGER = logging.getLogger(\"cfnlint\")\n\nsamtranslator_logger = logging.getLogger(\"samtranslator\")\nsamtranslator_logger.setLevel(logging.CRITICAL)\n\n\n# Override SAM validation as cfn-lint does thoese\n# checks already\n# pylint: disable=unused-argument\ndef valid_override(self):\n    return resource.SamResourceType.has_value(self.type)\n\n\n# pylint: disable=redefined-outer-name\nresource.SamResource.valid = valid_override\n\n\nclass Transform:\n    \"\"\"\n    Application Serverless Module tranform Wrapper.\n    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        self._parameters = {}\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 load_resource(Serverless, \"ManagedPolicies.json\")\n\n    def _replace_local_codeuri(self):\n        \"\"\"\n        Replaces the CodeUri in AWS::Serverless::Function and DefinitionUri in\n        AWS::Serverless::Api to a fake S3 Uri. This is to support running the\n        SAM Translator with valid values for these fields. If this is not done,\n        the template is invalid in the eyes of SAM Translator (the translator\n        does not support local paths)\n        \"\"\"\n\n        all_resources = self._template.get(\"Resources\", {})\n\n        template_globals = self._template.get(\"Globals\", {})\n        auto_publish_alias = template_globals.get(\"Function\", {}).get(\n            \"AutoPublishAlias\"\n        )\n        if isinstance(auto_publish_alias, dict):\n            if len(auto_publish_alias) == 1:\n                for k, v in auto_publish_alias.items():\n                    if k == \"Ref\":\n                        if v in self._template.get(\"Parameters\"):\n                            self._parameters[v] = \"Alias\"\n\n        for _, resource in all_resources.items():\n            resource_type = resource.get(\"Type\")\n            resource_dict = resource.get(\"Properties\")\n\n            if resource_type == \"AWS::Serverless::Function\":\n                if resource_dict.get(\"PackageType\") == \"Image\":\n                    Transform._update_to_s3_uri(\"ImageUri\", resource_dict)\n                else:\n                    Transform._update_to_s3_uri(\"CodeUri\", resource_dict)\n                auto_publish_alias = resource_dict.get(\"AutoPublishAlias\")\n                if isinstance(auto_publish_alias, dict):\n                    if len(auto_publish_alias) == 1:\n                        for k, v in auto_publish_alias.items():\n                            if k == \"Ref\":\n                                if v in self._template.get(\"Parameters\"):\n                                    self._parameters[v] = \"Alias\"\n            if resource_type in [\"AWS::Serverless::LayerVersion\"]:\n                if resource_dict.get(\"ContentUri\"):\n                    Transform._update_to_s3_uri(\"ContentUri\", resource_dict)\n            if resource_type == \"AWS::Serverless::Application\":\n                if resource_dict.get(\"Location\"):\n                    if isinstance(resource_dict.get(\"Location\"), dict):\n                        resource_dict[\"Location\"] = \"\"\n                        Transform._update_to_s3_uri(\"Location\", resource_dict)\n            if resource_type == \"AWS::Serverless::Api\":\n                if (\n                    \"DefinitionBody\" not in resource_dict\n                    and \"Auth\" not in resource_dict\n                    and \"Cors\" not in resource_dict\n                    and \"DisableExecuteApiEndpoint\" not in resource_dict\n                ):\n                    Transform._update_to_s3_uri(\"DefinitionUri\", resource_dict)\n                else:\n                    resource_dict[\"DefinitionBody\"] = \"\"\n            if resource_type == \"AWS::Serverless::StateMachine\" and resource_dict.get(\n                \"DefinitionUri\"\n            ):\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            # Output the SAM Translator version in debug mode\n            LOGGER.info(\"SAM Translator: %s\", samtranslator.__version__)\n\n            sam_translator = Translator(\n                managed_policy_map=self._managed_policy_map, sam_parser=self._sam_parser\n            )\n\n            self._replace_local_codeuri()\n\n            # Tell SAM to use the region we're linting in, this has to be\n            # controlled using the default AWS mechanisms, see also:\n            # https://github.com/awslabs/serverless-application-model/blob/master/samtranslator/translator/arn_generator.py\n            LOGGER.info(\"Setting AWS_DEFAULT_REGION to %s\", self._region)\n            os.environ[\"AWS_DEFAULT_REGION\"] = self._region\n\n            self._template = convert_dict(\n                sam_translator.translate(\n                    sam_template=self._template, parameter_values=self._parameters\n                )\n            )\n\n            LOGGER.info(\n                \"Transformed template: \\n%s\", format_json_string(self._template)\n            )\n        except InvalidDocumentException as e:\n            message = \"Error transforming template: {0}\"\n            for cause in e.causes:\n                matches.append(\n                    Match(\n                        1,\n                        1,\n                        1,\n                        1,\n                        self._filename,\n                        TransformError(),\n                        message.format(cause.message),\n                    )\n                )\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(\n                Match(\n                    1, 1, 1, 1, self._filename, TransformError(), message.format(str(e))\n                )\n            )\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, str) and uri.startswith(\"s3://\")\n\n    @staticmethod\n    def _update_to_s3_uri(\n        property_key, resource_property_dict, s3_uri_value=\"s3://bucket/value\"\n    ):\n        \"\"\"\n        Updates the 'property_key' in the 'resource_property_dict' to the\n        value of 's3_uri_value'\n        Note: The function will mutate the resource_property_dict that is pass\n        in 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):\n            if len(uri_property) == 1:\n                for k in uri_property.keys():\n                    if k == \"Ref\":\n                        resource_property_dict[property_key] = s3_uri_value\n            return\n        if Transform.is_s3_uri(uri_property):\n            return\n\n        resource_property_dict[property_key] = s3_uri_value\n", "path": "src/cfnlint/transform.py"}]}