Repository: aws-cloudformation/cfn-lint

Issue:
AWS::Serverless::StateMachine.DefinitionUri support for local files
*cfn-lint version: 0.32.1*

*Description of issue.*

The recent release of SAM support for Step Functions has added the ability to use a non-S3 URL for the [`DefinitionUri`](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html#sam-statemachine-definitionuri) in order to reference local files that get included during a deploy. The linter is currently throwing an error for all non-S3 values, though.

```
[cfn-lint] E0001: Error transforming template: Resource with id [StateMachine] is invalid. 'DefinitionUri' is not a valid S3 Uri of the form 's3://bucket/key' with optional versionId query parameter.
```


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -45,7 +45,7 @@ def get_version(filename):
         'pyyaml<=5.2;python_version=="3.4"',
         'pyyaml;python_version!="3.4"',
         'six~=1.11',
-        'aws-sam-translator>=1.23.0',
+        'aws-sam-translator>=1.24.0',
         'jsonpatch;python_version!="3.4"',
         'jsonpatch<=1.24;python_version=="3.4"',
         'jsonschema~=3.0',
diff --git a/src/cfnlint/transform.py b/src/cfnlint/transform.py
--- a/src/cfnlint/transform.py
+++ b/src/cfnlint/transform.py
@@ -85,6 +85,8 @@ def _replace_local_codeuri(self):
                     Transform._update_to_s3_uri('DefinitionUri', resource_dict)
                 else:
                     resource_dict['DefinitionBody'] = ''
+            if resource_type == 'AWS::Serverless::StateMachine':
+                Transform._update_to_s3_uri('DefinitionUri', resource_dict)
 
     def transform_template(self):
         """


Test patch:
diff --git a/test/fixtures/templates/good/transform/step_function_local_definition.yaml b/test/fixtures/templates/good/transform/step_function_local_definition.yaml
new file mode 100644
--- /dev/null
+++ b/test/fixtures/templates/good/transform/step_function_local_definition.yaml
@@ -0,0 +1,12 @@
+Transform: AWS::Serverless-2016-10-31
+Resources:
+  StateMachine:
+    Type: AWS::Serverless::StateMachine
+    Properties:
+      DefinitionUri: ./test.json
+      Policies:
+        - Version: "2012-10-17"
+          Statement:
+            - Effect: Deny
+              Action: "*"
+              Resource: "*"
diff --git a/test/unit/module/transform/test_transform.py b/test/unit/module/transform/test_transform.py
--- a/test/unit/module/transform/test_transform.py
+++ b/test/unit/module/transform/test_transform.py
@@ -28,6 +28,21 @@ def test_parameter_for_autopublish_version(self):
                 'FunctionVersion': {'Fn::GetAtt': ['SkillFunctionVersion55ff35af87', 'Version']}
             })
 
+    def test_conversion_of_step_function_definition_uri(self):
+        """ Tests that the a serverless step function can convert a local path to a s3 path """
+        filename = 'test/fixtures/templates/good/transform/step_function_local_definition.yaml'
+        region = 'us-east-1'
+        template = cfn_yaml.load(filename)
+        transformed_template = Transform(filename, template, region)
+        transformed_template.transform_template()
+        self.assertDictEqual(
+            transformed_template._template.get('Resources').get(
+                'StateMachine').get('Properties').get('DefinitionS3Location'),
+            {
+                'Bucket': 'bucket',
+                'Key': 'value'
+            })
+
     def test_parameter_for_autopublish_version_bad(self):
         """Test Parameter is created for autopublish version run"""
         filename = 'test/fixtures/templates/bad/transform/auto_publish_alias.yaml'