AWS Stepfunctions发电机数据库状态.运行时捕获失败



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

当它与项匹配时,它会按预期工作,因为当发电机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
}   } }

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

这是代码。

{
"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
}
}
}

相关内容

  • 没有找到相关文章