{
  "Comment": "Trigger a scheduled product metadata update",
  "StartAt": "UpdateProductValues",
  "States": {
    "UpdateProductValues": {
      "Type": "Task",
      "Resource": "${lambda_update_product_values_arn}",
      "ResultPath": "$.updateProductValuesResult",
      "Next": "UpdateMetadataQueue",
      "Retry": [
        {
          "ErrorEquals": [ "UpdateProductValuesFailed" ],
          "IntervalSeconds": 5,
          "MaxAttempts": 3,
          "BackoffRate": 3
        },
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [ 
        {
          "ErrorEquals": [ "States.ALL" ],
          "ResultPath": "$.error",
          "Next": "NotifyLabelManager"
        } 
      ]
    },
    "UpdateMetadataQueue": {
      "Type": "Task",
      "Resource": "${lambda_update_metadata_queue_arn}",
      "ResultPath": "$.updateMetadataQueueResult",
      "Next": "NotifyLabelManager",
      "Retry": [
        {
          "ErrorEquals": [ "UpdateMetadataQueueFailed" ],
          "IntervalSeconds": 5,
          "MaxAttempts": 3,
          "BackoffRate": 3
        },
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [ 
        {
          "ErrorEquals": [ "States.ALL" ],
          "ResultPath": "$.error",
          "Next": "NotifyLabelManager"
        } 
      ]
    },
    "NotifyLabelManager": {
      "Type": "Task",
      "Resource": "${lambda_notify_label_manager_arn}",
      "ResultPath": "$.notifyLabelManagerResult",
      "Next": "HandleError",
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [ 
        {
          "ErrorEquals": [ "States.ALL" ],
          "ResultPath": "$.error",
          "Next": "FailState"
        }
      ]
    },
    "HandleError": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.error",
          "IsPresent": false,
          "Next": "SuccessState"
        },
        {
          "Variable": "$.error",
          "IsPresent": true,
          "Next": "FailState"
        }
      ]
    },
    "SuccessState": {
      "Type": "Succeed"
    },
    "FailState": {
      "Type": "Fail",
      "ErrorPath": "$.error.Error",
      "CausePath": "$.error.Cause"
    }
  }
}