我在使用 stepfunction 从 AWS dynamoDB 获取数据时收到错误“提供的关键元素与架构不匹配”。
阶跃函数定义
{
"Comment": "This is your state machine",
"StartAt": "Choice",
"States": {
"Choice": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.data.Type",
"StringEquals": "GET",
"Next": "DynamoDB GetItem"
},
{
"Variable": "$.data.Type",
"StringEquals": "PUT",
"Next": "DynamoDB PutItem"
}
]
},
"DynamoDB GetItem": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "KeshavDev",
"Key": {
"Email": {
"S": "$.Email"
}
}
},
"End": true
},
"DynamoDB PutItem": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:putItem",
"Parameters": {
"TableName": "KeshavDev",
"Item": {
"City": {
"S.$": "$.City"
},
"Email": {
"S.$": "$.Email"
},
"Address": {
"S.$": "$.Address"
}
}
},
"InputPath": "$.data",
"End": true
}
}
}
输入
{
"data": {
"Type": "GET",
"Email": "demo@gmail.com"
}
}
错误
<块引用>{ "resourceType": "dynamodb", "resource": "getItem", "error": "DynamoDB.AmazonDynamoDBException", "cause": "提供的密钥 元素与架构不匹配(服务:AmazonDynamoDBv2;状态 代码:400;错误代码:验证异常;请求 ID: a78c3d7a-ca3f-4483-b986-1735201d4ef2;代理:空)" }
答案 0 :(得分:0)
与 AWS documentation 相比,我发现 S.$
任务存在一些潜在问题。
putItem
字段需要 ResultPath
类似于您在 $.data.Email
任务中的内容。 "DynamoDB GetItem": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "KeshavDev",
"Key": {
"Email": {
"S.$": "$.data.Email"
}
}
},
"ResultPath": "$.DynamoDB",
"End": true
},
属性告诉状态机将结果放在哪里。java.lang.IllegalStateException: Could not find the HAPI-FHIR structure JAR on the classpath for version R4. Note that as of HAPI-FHIR v0.8, a separate FHIR strcture JAR must be added to your classpath (or project pom.xml if you are using Maven)
at ca.uhn.fhir.context.FhirContext.<init>(Unknown Source:114)
at ca.uhn.fhir.context.FhirContext.<init>(Unknown Source:1)
at ca.uhn.fhir.context.FhirContext.forR4(Unknown Source:4)
at e.f.a.m0.a.a.a(:12)
at androidx.lifecycle.LiveData.b(Unknown Source:29)
at androidx.lifecycle.LiveData.c(Unknown Source:44)
at b.s.q.h(:1)
at e.p.a.c$c.b(:2)
at m.b.run(:1)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7562)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
nodes = {1: {'pos': (1, 2), 'other_data': 'N/A'},
2: {'pos': (2, 2), 'other_data': 'N/A'},
3: {'pos': (4, 3), 'other_data': 'N/A'},
4: {'pos': (5, 3), 'other_data': 'N/A'},
5: {'pos': (6, 3), 'other_data': 'N/A'},
6: {'pos': (1, 4), 'other_data': 'N/A'},
7: {'pos': (2, 4), 'other_data': 'N/A'},
8: {'pos': (4, 5), 'other_data': 'N/A'},
9: {'pos': (5, 5), 'other_data': 'N/A'},
10: {'pos': (6, 5), 'other_data': 'N/A'}}
老实说,我不确定所有这些中的一个是否会导致验证错误,这些是一些需要试验的东西。
另外,Amazon State Language 有一些开源的 validators,但在这种情况下,它们不是很有帮助,并且表示您的代码是有效的。
答案 1 :(得分:0)
它的工作,通过在步骤函数定义中添加两个键。 DynamoDb 有两个键。