【问题标题】:AWS Stepfunctions dynamodb States.Runtime catch failsAWS Stepfunctions dynamodb States.Runtime 捕获失败
【发布时间】:2020-12-27 12:03:04
【问题描述】:

我的 Stepfunction 应该检查发电机中是否存在项目。如果是,则需要生成预签名的 url,否则必须更新 dynamodb 项。

当它与项目匹配时,它会按预期工作,因为当 dynamo getitem 输出为 null 时失败并出现 states.runtime 错误。它不通过 catch 语句。感谢任何帮助。

这是我的代码。

{   "Comment": "A Hello World example of the Amazon States Language using Pass states",   "StartAt": "Hello",   "States": {
    "Hello": {
      "Type": "Pass",
      "Next": "Verify item from DynamoDB"
    },
    "s3_url": {
      "Type": "Pass",
      "Result": "Hello",
      "End": true
    },

    "Verify item from DynamoDB": {
      "Type": "Task",
      "Resource": "arn:aws:states:::dynamodb:getItem",
      "Parameters": {
        "TableName": "s3_table",
        "Key": {
          "etag": {
            "S.$": "$.Records[0].s3.object.eTag"
          }
        }
      },
      "ResultPath": "$.DynamoDB",
      "OutputPath": "$.DynamoDB.Item",
      "Next": "s3_url",
      "Catch": [
        {
          "ErrorEquals": [
            "States.Runtime"
          ],
        
          "Next": "DynamoDB Update"
        }
      ]
    },
    "DynamoDB Update": {
      "Type": "Task",
      "Resource": "arn:aws:states:::dynamodb:putItem",
      "Parameters": {
        "TableName": "s3_table",
        "Item": {
          "etag": {
            "S.$": "$.eTag"
          },
          "filekey": {
            "S": "mp3Files"
          }
        }
      },
      "End": true
    }   } }

【问题讨论】:

    标签: amazon-dynamodb aws-step-functions


    【解决方案1】:

    使用选择状态解决了这个问题。打开以听取有关 Catch 状态的任何建议。

    这里是代码。

    {
      "Comment": "A Hello World example of the Amazon States Language using Pass states",
      "StartAt": "Hello",
      "States": {
        "Hello": {
          "Type": "Pass",
          "Next": "Verify item from DynamoDB"
        },
        "s3_url": {
          "Type": "Pass",
          "Result": "Hello",
          "End": true
        },
        "Verify item from DynamoDB": {
          "Type": "Task",
          "Resource": "arn:aws:states:::dynamodb:getItem",
          "Parameters": {
           
            "TableName": "s3_table",
            "Key": {
              "etag": {
                "S.$": "$.Records[0].s3.object.eTag"
              }
            }
          },
          "ResultPath": "$.Records[0].DynamoDB",
          "OutputPath": "$",
          "Next": "Choice State",
          "Catch": [
            {
              "ErrorEquals": [
                "States.Runtime"
              ],
              "Next": "DynamoDB Update"
            }
          ]
        },
         "Choice State": {
          "Type": "Choice",
          "Choices": [
            {
              "Variable": "$.Records[0].DynamoDB.Item.etag.S",
              "IsPresent": true,
              "Next": "s3_url"
            }
          ],
          "Default": "DynamoDB Update"
        },
        "DynamoDB Update": {
          "Type": "Task",
          "Resource": "arn:aws:states:::dynamodb:putItem",
          "Parameters": {
            "TableName": "s3_table",
            "Item": {
              "etag": {
                "S.$": "$.Records[0].s3.object.eTag"
              },
              "filekey": {
                "S.$": "$.Records[0].s3.object.key"
              }
            }
          },
          "End": true
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-24
      • 2019-06-02
      • 1970-01-01
      相关资源
      最近更新 更多