{
  "Comment": "A Step function to demonstrate creating a SQL instance then running additional commands on it via SSM",
  "StartAt": "Create SQL Instance",
  "States": {
    "Create SQL Instance": {
      "Comment": "Invoke Lambda that will create SQL instance",
      "Type": "Task",
      "Resource": "arn:aws:lambda:lambda_region:lambda_acctid:function:create_instance",
      "InputPath": "$",
      "ResultPath": "$",
      "Next": "Restore Backup"
    },
    "Restore Backup": {
      "Comment": "Restore Backup on SQL instance",
      "Type": "Task",
      "Resource": "arn:aws:lambda:lambda_region:lambda_acctid:function:run_sql_command",
      "InputPath": "$",
      "ResultPath": "$",
      "Next": "Wait For Command",
      "Retry": [
        {
          "ErrorEquals": [
            "InvalidInstanceId",
            "IncorrectInstanceState",
            "ClientError",
            "InstanceNotReady",
            "ParameterNotFound"
          ],
          "IntervalSeconds": 60,
          "MaxAttempts": 5,
          "BackoffRate": 1
        }
      ]
    },
    "Wait For Command": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:lambda_region:lambda_acctid:function:wait_sql_command",
      "InputPath": "$",
      "Next": "Done",
      "Retry": [
        {
          "ErrorEquals": [
            "WaiterError"
          ],
          "IntervalSeconds": 60,
          "MaxAttempts": 5,
          "BackoffRate": 1
        }
      ]
    },
    "Done": {
      "Type": "Pass",
      "End": true
    }
  }}
