Last active
December 20, 2022 09:05
-
-
Save studds/b9dbba056eaaaf42dfe70c191c12d848 to your computer and use it in GitHub Desktop.
JSON Schema for AWS Step Functions (derived from https://github.com/airware/asl-validator)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://json-schema.org/draft-07/schema", | |
"definitions": { | |
"state-machine": { | |
"type": "object", | |
"properties": { | |
"Comment": { | |
"type": "string" | |
}, | |
"StartAt": { | |
"type": "string" | |
}, | |
"States": { | |
"type": "object", | |
"patternProperties": { | |
"^.{1,128}$": { | |
"$ref": "#/definitions/state" | |
} | |
}, | |
"additionalProperties": false | |
}, | |
"Version": { | |
"type": "string" | |
}, | |
"TimeoutSeconds": { | |
"type": "integer", | |
"minimum": 0 | |
} | |
}, | |
"additionalProperties": false, | |
"required": ["StartAt", "States"] | |
}, | |
"choice": { | |
"definitions": { | |
"Operator": { | |
"type": "object", | |
"properties": { | |
"Variable": { | |
"type": "string" | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
}, | |
"And": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/choice/definitions/Operator" | |
} | |
}, | |
"Or": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/choice/definitions/Operator" | |
} | |
}, | |
"Not": { | |
"$ref": "#/definitions/choice/definitions/Operator" | |
}, | |
"BooleanEquals": { | |
"type": "boolean" | |
}, | |
"NumericEquals": { | |
"type": "number" | |
}, | |
"NumericGreaterThan": { | |
"type": "number" | |
}, | |
"NumericGreaterThanEquals": { | |
"type": "number" | |
}, | |
"NumericLessThan": { | |
"type": "number" | |
}, | |
"NumericLessThanEquals": { | |
"type": "number" | |
}, | |
"StringEquals": { | |
"type": "string" | |
}, | |
"StringGreaterThan": { | |
"type": "string" | |
}, | |
"StringGreaterThanEquals": { | |
"type": "string" | |
}, | |
"StringLessThan": { | |
"type": "string" | |
}, | |
"StringLessThanEquals": { | |
"type": "string" | |
}, | |
"TimestampEquals": { | |
"type": "string" | |
}, | |
"TimestampGreaterThan": { | |
"type": "string" | |
}, | |
"TimestampGreaterThanEquals": { | |
"type": "string" | |
}, | |
"TimestampLessThan": { | |
"type": "string" | |
}, | |
"TimestampLessThanEquals": { | |
"type": "string" | |
} | |
}, | |
"oneOf": [ | |
{ | |
"required": ["And"] | |
}, | |
{ | |
"required": ["BooleanEquals"] | |
}, | |
{ | |
"required": ["Not"] | |
}, | |
{ | |
"required": ["NumericEquals"] | |
}, | |
{ | |
"required": ["NumericGreaterThan"] | |
}, | |
{ | |
"required": ["NumericGreaterThanEquals"] | |
}, | |
{ | |
"required": ["NumericLessThan"] | |
}, | |
{ | |
"required": ["NumericLessThanEquals"] | |
}, | |
{ | |
"required": ["Or"] | |
}, | |
{ | |
"required": ["StringEquals"] | |
}, | |
{ | |
"required": ["StringGreaterThan"] | |
}, | |
{ | |
"required": ["StringGreaterThanEquals"] | |
}, | |
{ | |
"required": ["StringLessThan"] | |
}, | |
{ | |
"required": ["StringLessThanEquals"] | |
}, | |
{ | |
"required": ["TimestampEquals"] | |
}, | |
{ | |
"required": ["TimestampGreaterThan"] | |
}, | |
{ | |
"required": ["TimestampGreaterThanEquals"] | |
}, | |
{ | |
"required": ["TimestampLessThan"] | |
}, | |
{ | |
"required": ["TimestampLessThanEquals"] | |
} | |
] | |
} | |
}, | |
"type": "object", | |
"properties": { | |
"Type": { | |
"type": "string", | |
"enum": ["Choice"] | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
}, | |
"End": { | |
"enum": [true] | |
}, | |
"Comment": { | |
"type": "string" | |
}, | |
"OutputPath": { | |
"type": ["string", "null"] | |
}, | |
"InputPath": { | |
"type": ["string", "null"] | |
}, | |
"Choices": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/choice/definitions/Operator" | |
} | |
}, | |
"Default": { | |
"type": "string" | |
} | |
}, | |
"required": ["Type", "Choices"], | |
"additionalProperties": false | |
}, | |
"fail": { | |
"type": "object", | |
"properties": { | |
"Type": { | |
"type": "string", | |
"enum": ["Fail"] | |
}, | |
"Comment": { | |
"type": "string" | |
}, | |
"OutputPath": { | |
"type": ["string", "null"] | |
}, | |
"InputPath": { | |
"type": ["string", "null"] | |
}, | |
"Cause": { | |
"type": "string" | |
}, | |
"Error": { | |
"type": "string" | |
} | |
}, | |
"required": ["Type"], | |
"additionalProperties": false | |
}, | |
"map": { | |
"type": "object", | |
"properties": { | |
"Type": { | |
"type": "string", | |
"enum": ["Map"] | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
}, | |
"End": { | |
"enum": [true] | |
}, | |
"Comment": { | |
"type": "string" | |
}, | |
"OutputPath": { | |
"type": ["string", "null"] | |
}, | |
"InputPath": { | |
"type": ["string", "null"] | |
}, | |
"ResultPath": { | |
"type": ["string", "null"] | |
}, | |
"ItemsPath": { | |
"type": ["string", "null"] | |
}, | |
"MaxConcurrency": { | |
"type": "number", | |
"minimum": 0 | |
}, | |
"Iterator": { | |
"$ref": "#/definitions/state-machine" | |
}, | |
"Parameters": { | |
"type": "object" | |
}, | |
"Retry": { | |
"type": "array", | |
"items": { | |
"types": "object", | |
"properties": { | |
"ErrorEquals": { | |
"type": "array", | |
"items": { | |
"types": "string" | |
} | |
}, | |
"IntervalSeconds": { | |
"type": "number", | |
"minimum": 0 | |
}, | |
"MaxAttempts": { | |
"type": "number", | |
"minimum": 0 | |
}, | |
"BackoffRate": { | |
"type": "number", | |
"minimum": 0 | |
} | |
}, | |
"required": ["ErrorEquals"] | |
} | |
}, | |
"Catch": { | |
"type": "array", | |
"items": { | |
"types": "object", | |
"properties": { | |
"ErrorEquals": { | |
"type": "array", | |
"items": { | |
"types": "string" | |
} | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
} | |
}, | |
"required": ["ErrorEquals", "Next"] | |
} | |
} | |
}, | |
"oneOf": [ | |
{ | |
"required": ["Next"] | |
}, | |
{ | |
"required": ["End"] | |
} | |
], | |
"required": ["Type", "Iterator"], | |
"additionalProperties": false | |
}, | |
"parallel": { | |
"type": "object", | |
"properties": { | |
"Type": { | |
"type": "string", | |
"enum": ["Parallel"] | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
}, | |
"End": { | |
"enum": [true] | |
}, | |
"Comment": { | |
"type": "string" | |
}, | |
"OutputPath": { | |
"type": ["string", "null"] | |
}, | |
"InputPath": { | |
"type": ["string", "null"] | |
}, | |
"ResultPath": { | |
"type": ["string", "null"] | |
}, | |
"Branches": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/state-machine" | |
} | |
}, | |
"Retry": { | |
"type": "array", | |
"items": { | |
"types": "object", | |
"properties": { | |
"ErrorEquals": { | |
"type": "array", | |
"items": { | |
"types": "string" | |
} | |
}, | |
"IntervalSeconds": { | |
"type": "number", | |
"minimum": 0 | |
}, | |
"MaxAttempts": { | |
"type": "number", | |
"minimum": 0 | |
}, | |
"BackoffRate": { | |
"type": "number", | |
"minimum": 0 | |
} | |
}, | |
"required": ["ErrorEquals"] | |
} | |
}, | |
"Catch": { | |
"type": "array", | |
"items": { | |
"types": "object", | |
"properties": { | |
"ErrorEquals": { | |
"type": "array", | |
"items": { | |
"types": "string" | |
} | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
} | |
}, | |
"required": ["ErrorEquals", "Next"] | |
} | |
} | |
}, | |
"oneOf": [ | |
{ | |
"required": ["Next"] | |
}, | |
{ | |
"required": ["End"] | |
} | |
], | |
"required": ["Type", "Branches"], | |
"additionalProperties": false | |
}, | |
"pass": { | |
"type": "object", | |
"properties": { | |
"Type": { | |
"type": "string", | |
"enum": ["Pass"] | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
}, | |
"End": { | |
"enum": [true] | |
}, | |
"Comment": { | |
"type": "string" | |
}, | |
"OutputPath": { | |
"type": ["string", "null"] | |
}, | |
"InputPath": { | |
"type": ["string", "null"] | |
}, | |
"ResultPath": { | |
"type": "string" | |
}, | |
"Parameters": { | |
"type": "object" | |
}, | |
"Result": {} | |
}, | |
"oneOf": [ | |
{ | |
"required": ["Next"] | |
}, | |
{ | |
"required": ["End"] | |
} | |
], | |
"required": ["Type"], | |
"additionalProperties": false | |
}, | |
"state": { | |
"type": "object", | |
"oneOf": [ | |
{ | |
"$ref": "#/definitions/choice" | |
}, | |
{ | |
"$ref": "#/definitions/fail" | |
}, | |
{ | |
"$ref": "#/definitions/parallel" | |
}, | |
{ | |
"$ref": "#/definitions/pass" | |
}, | |
{ | |
"$ref": "#/definitions/succeed" | |
}, | |
{ | |
"$ref": "#/definitions/task" | |
}, | |
{ | |
"$ref": "#/definitions/wait" | |
}, | |
{ | |
"$ref": "#/definitions/map" | |
} | |
] | |
}, | |
"succeed": { | |
"type": "object", | |
"properties": { | |
"Type": { | |
"type": "string", | |
"enum": ["Succeed"] | |
}, | |
"Comment": { | |
"type": "string" | |
} | |
}, | |
"required": ["Type"], | |
"additionalProperties": false | |
}, | |
"task": { | |
"type": "object", | |
"properties": { | |
"Type": { | |
"type": "string", | |
"enum": ["Task"] | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
}, | |
"End": { | |
"enum": [true] | |
}, | |
"Comment": { | |
"type": "string" | |
}, | |
"OutputPath": { | |
"type": ["string", "null"] | |
}, | |
"InputPath": { | |
"type": ["string", "null"] | |
}, | |
"Resource": { | |
"oneOf": [ | |
{ | |
"type": "string", | |
"pattern": "^arn:aws:([a-z]|-)+:([a-z]|[0-9]|-)*:[0-9]*:([a-z]|-)+:[a-zA-Z0-9-_.]+(:(\\$LATEST|[a-zA-Z0-9-_]+))?$" | |
}, | |
{ | |
"type": "object" | |
} | |
] | |
}, | |
"ResultPath": { | |
"type": ["string", "null"] | |
}, | |
"Retry": { | |
"type": "array", | |
"items": { | |
"types": "object", | |
"properties": { | |
"ErrorEquals": { | |
"type": "array", | |
"items": { | |
"types": "string" | |
} | |
}, | |
"IntervalSeconds": { | |
"type": "number", | |
"minimum": 0 | |
}, | |
"MaxAttempts": { | |
"type": "number", | |
"minimum": 0 | |
}, | |
"BackoffRate": { | |
"type": "number", | |
"minimum": 0 | |
} | |
}, | |
"required": ["ErrorEquals"] | |
} | |
}, | |
"Catch": { | |
"type": "array", | |
"items": { | |
"types": "object", | |
"properties": { | |
"ErrorEquals": { | |
"type": "array", | |
"items": { | |
"types": "string" | |
} | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
} | |
}, | |
"required": ["ErrorEquals", "Next"] | |
} | |
}, | |
"TimeoutSeconds": { | |
"type": "number", | |
"minimum": 1 | |
}, | |
"HeartbeatSeconds": { | |
"type": "number", | |
"minimum": 1 | |
}, | |
"Parameters": { | |
"type": "object" | |
} | |
}, | |
"oneOf": [ | |
{ | |
"required": ["Next"] | |
}, | |
{ | |
"required": ["End"] | |
} | |
], | |
"required": ["Type", "Resource"], | |
"additionalProperties": false | |
}, | |
"wait": { | |
"type": "object", | |
"properties": { | |
"Type": { | |
"type": "string", | |
"enum": ["Wait"] | |
}, | |
"Next": { | |
"type": "string", | |
"pattern": "^.{1,128}$" | |
}, | |
"End": { | |
"enum": [true] | |
}, | |
"Comment": { | |
"type": "string" | |
}, | |
"OutputPath": { | |
"type": ["string", "null"] | |
}, | |
"InputPath": { | |
"type": ["string", "null"] | |
}, | |
"Seconds": { | |
"type": "number", | |
"minimum": 0 | |
}, | |
"Timestamp": { | |
"type": "string" | |
}, | |
"SecondsPath": { | |
"type": ["string", "null"] | |
}, | |
"TimestampPath": { | |
"type": ["string", "null"] | |
} | |
}, | |
"oneOf": [ | |
{ | |
"required": ["Next"] | |
}, | |
{ | |
"required": ["End"] | |
} | |
], | |
"required": ["Type"], | |
"additionalProperties": false | |
} | |
}, | |
"$ref": "#/definitions/state-machine" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, this is incredibly useful! Makes auto-completion/validation in my IDE a breeze. Not sure why AWS itself doesn't vend this schema.
You might want to open an issue against somewhere in https://github.com/awslabs and see if you can:
1: Get them to adopt this (and therefore maintain it going forwards) into one of their repos.
2: Once adopted, they'd be able to mention it in their docs somewhere under here: https://docs.aws.amazon.com/step-functions/
Regardless of whether or not AWS adopt it, thanks once again for a useful tool!