仅供参考:目前使用的是AppSync + React + Apollo,我正在尝试通过AppSync的Apache VTL发送38 - 40个项目进行更新。
我知道DynamoDB限制了插入到25 per request中的项目数量,但我认为AppSync没有这些限制。我想我错了,因为每当我发送超过25个项目(26+)时,我的请求都会失败。
下面是我的VTL脚本:
#set($isTenantValid = false)
#foreach($tenant in $context.identity.claims["https://app.schon.io/tenants"])
#if($tenant == $ctx.args.tenantId)
#set($isTenantValid = true)
#end
#end
## Needs to verify if the employee has permission to insert students.
#if(!$isTenantValid)
$utils.unauthorized()
#end
#set($itemsToPut=[])
#set($pk="tenant:${ctx.args.tenantId}")
#set($userSK="tenant:${ctx.args.tenantId}:school-year:${ctx.args.schoolYear}")
#foreach($student in $ctx.args.students)
#set($studentId = "${util.autoId()}")
#set($sk="school-year:${ctx.args.schoolYear}:student:${studentId}")
#set($userPK="student:${studentId}")
#set($item = {
"pk": $pk,
"sk": $sk,
"id": $studentId,
"userPK": $userPK,
"userSK": $userSK,
"name": {
"firstName" : $student.name.firstName,
"lastName" : $student.name.lastName,
"fullName": "${student.name.firstName} ${student.name.lastName}"
},
"schoolYear": $ctx.args.schoolYear,
"createdAt": ${util.time.nowEpochSeconds()},
"updatedAt": ${util.time.nowEpochSeconds()},
"gender": $student.gender,
"retired": $student.retired
})
#if("${student.diseases}" != "")
$util.qr($item.add("diseases", $student.diseases))
#end
#if("${student.email}" != "")
$util.qr($item.add("email", $student.email))
#end
#if("${student.birthdate}" != "")
$util.qr($item.add("birthdate", $student.birthdate))
#end
$util.qr($itemsToPut.add($util.dynamodb.toMapValues($item)))
#end
{
"version" : "2018-05-29",
"operation" : "BatchPutItem",
"tables" : {
"SchonDB": $utils.toJson($itemsToPut)
}
}在这种情况下,我是否需要将其卸载到Lambda,并对每25个项目执行发送和重试逻辑?
发布于 2019-11-19 05:26:02
您是否可以尝试联系DDB团队,为您增加服务限制?
https://stackoverflow.com/questions/58908546
复制相似问题