ChristopheBougere/asl-validator

Why this template is invalid?

Closed this issue · 2 comments

asyba commented

Hi, first time using this script.

This is the sample from aws console:

{
  "Comment": "An example of the Amazon States Language for scheduling a task.",
  "StartAt": "Wait for Timestamp",
  "States": {
    "Wait for Timestamp": {
      "Type": "Wait",
      "SecondsPath": "$.timer_seconds",
      "Next": "Send SNS Message"
    },
    "Send SNS Message": {
      "Type": "Task",
      "Resource": "arn:0000000000:lambda:::function:SendToSNS",
      "Retry": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "IntervalSeconds": 1,
          "MaxAttempts": 3,
          "BackoffRate": 2
        }
      ],
      "End": true
    }
  }
}

This is the error:

asl-validator --json-path example.json
✕ State machine definition is invalid: [ { keyword: 'additionalProperties',
    dataPath: ".States['Send SNS Message']",
    schemaPath: '#/additionalProperties',
    params: { additionalProperty: 'Resource' },
    message: 'should NOT have additional properties' },
  { keyword: 'additionalProperties',
    dataPath: ".States['Send SNS Message']",
    schemaPath: 'http://asl-validator.cloud/fail#/additionalProperties',
    params: { additionalProperty: 'Resource' },
    message: 'should NOT have additional properties' },
  { keyword: 'additionalProperties',
    dataPath: ".States['Send SNS Message']",
    schemaPath: '#/additionalProperties',
    params: { additionalProperty: 'Resource' },
    message: 'should NOT have additional properties' },
  { keyword: 'additionalProperties',
    dataPath: ".States['Send SNS Message']",
    schemaPath: 'http://asl-validator.cloud/pass#/additionalProperties',
    params: { additionalProperty: 'Resource' },
    message: 'should NOT have additional properties' },
  { keyword: 'additionalProperties',
    dataPath: ".States['Send SNS Message']",
    schemaPath: 'http://asl-validator.cloud/succeed#/additionalProperties',
    params: { additionalProperty: 'Resource' },
    message: 'should NOT have additional properties' },
  { keyword: 'pattern',
    dataPath: ".States['Send SNS Message'].Resource",
    schemaPath:
     'http://asl-validator.cloud/task#/properties/Resource/pattern',
    params:
     { pattern: '^arn:aws:([a-z]|-)+:([a-z]|[0-9]|-)*:[0-9]*:([a-z]|-)+:.+$' },
    message:
     'should match pattern "^arn:aws:([a-z]|-)+:([a-z]|[0-9]|-)*:[0-9]*:([a-z]|-)+:.+$"' },
  { keyword: 'additionalProperties',
    dataPath: ".States['Send SNS Message']",
    schemaPath: 'http://asl-validator.cloud/wait#/additionalProperties',
    params: { additionalProperty: 'Resource' },
    message: 'should NOT have additional properties' },
  { keyword: 'oneOf',
    dataPath: ".States['Send SNS Message']",
    schemaPath: '#/oneOf',
    params: { passingSchemas: null },
    message: 'should match exactly one schema in oneOf' } ]


Hi,
Your Lambda ARN is malformed.
Try replacing it with this one: arn:aws:lambda::0000000000:function:SendToSNS and you'll get a valid result

asyba commented

ah okay, I was thinking that was another problem like the error is huge.
Thanks!