{
  "Comment": "Validate Bulk Asset Step Function",
  "StartAt": "AVScan",
  "States": {
    "AVScan": {
      "Type": "Task",
      "Resource": "${check_guardduty_scan_status_lambda_arn}",
      "Next": "ValidateAsset",
      "Retry": [
        {
          "ErrorEquals": [
            "NetworkException",
            "GraphQLException",
            "HTTPStatusError",
            "ReadTimeout",
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "BackoffRate": 2,
          "IntervalSeconds": 60,
          "MaxAttempts": 8,
          "Comment": "Retry 8 times with a backoff rate of 2"
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "HandleFailure",
          "ResultPath": "$.otherException",
          "Comment": "Error after retry"
        }
      ]
    },
    "ValidateAsset": {
      "Type": "Task",
      "Resource": "${validate_asset_lambda_arn}",
      "ResultPath": "$.validateAssetResult",
      "Retry": [
        {
          "ErrorEquals": [
            "NetworkException",
            "GraphQLException",
            "HTTPStatusError",
            "ReadTimeout",
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "BackoffRate": 2,
          "IntervalSeconds": 60,
          "MaxAttempts": 8,
          "Comment": "Retry 8 times with a backoff rate of 2"
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "HandleFailure",
          "ResultPath": "$.otherException",
          "Comment": "Error after retry"
        }
      ],
      "Next": "ChoiceAssetType"
    },
    "ChoiceAssetType": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.validateAssetResult.asset_type",
          "StringEquals": "audio",
          "Next": "ValidateAudio"
        },
        {
          "Variable": "$.validateAssetResult.asset_type",
          "StringEquals": "image",
          "Next": "ValidateImage"
        }
      ],
      "Default": "HandleFailure"
    },
    "ValidateAudio": {
      "Type": "Task",
      "Resource": "${validate_audio_lambda_arn}",
      "ResultPath": "$.audioValidationResult",
      "Retry": [
        {
          "ErrorEquals": [
            "NetworkException",
            "GraphQLException",
            "HTTPStatusError",
            "ReadTimeout",
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "BackoffRate": 2,
          "IntervalSeconds": 60,
          "MaxAttempts": 8,
          "Comment": "Retry 8 times with a backoff rate of 2"
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "HandleFailure",
          "ResultPath": "$.otherException",
          "Comment": "Error after retry"
        }
      ],
      "Next": "UpdateAssetStatus"
    },
    "ValidateImage": {
      "Type": "Task",
      "Resource": "${validate_image_lambda_arn}",
      "ResultPath": "$.imageValidationResult",
      "Retry": [
        {
          "ErrorEquals": [
            "NetworkException",
            "GraphQLException",
            "HTTPStatusError",
            "ReadTimeout",
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "BackoffRate": 2,
          "IntervalSeconds": 60,
          "MaxAttempts": 8,
          "Comment": "Retry 8 times with a backoff rate of 2"
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "HandleFailure",
          "ResultPath": "$.otherException",
          "Comment": "Error after retry"
        }
      ],
      "Next": "UpdateAssetStatus"
    },
    "UpdateAssetStatus": {
      "Type": "Task",
      "Resource": "${update_asset_status_lambda_arn}",
      "Retry": [
        {
          "ErrorEquals": [
            "NetworkException",
            "GraphQLException",
            "HTTPStatusError",
            "ReadTimeout",
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "BackoffRate": 2,
          "IntervalSeconds": 60,
          "MaxAttempts": 8,
          "Comment": "Retry 8 times with a backoff rate of 2"
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "HandleFailure",
          "ResultPath": "$.otherException",
          "Comment": "Error after retry"
        }
      ],
      "Next": "SuccessState"
    },
    "HandleFailure": {
      "Type": "Task",
      "Resource": "${handle_asset_failure_lambda_arn}",
      "Next": "FailureState"
    },
    "SuccessState": {
      "Type": "Succeed"
    },
    "FailureState": {
      "Type": "Fail"
    }
  }
}
