How can I authorize a custom function handler to perform a "dynamodb:BatchWriteItem"?
Here is my mutation:
{
...otherPartsOfSchema
likePost: a
.mutation()
.arguments({
postId: a.string(),
})
.returns(a.json())
.authorization((allow) => [allow.publicApiKey()])
.handler(
a.handler.custom({
dataSource: a.ref('Todo'),
entry: './increment-like.js',
})
)
}
In my increment-like.js file, I can successfully call a non-batch write operation like "UpdateItem", but can not call an operation like "BatchPutItem".
Here's the successful UpdateItem operation
export function request(ctx) {
return {
operation: 'UpdateItem',
key: util.dynamodb.toMapValues({ id: ctx.args.id }),
update: {
expression: 'SET content = :newContent',
expressionValues: { ':newContent': { S: "THIS HAS BEEN UPDATED" } },
}
}
}
Can you provide an example of how to authorize a custom handler to do batch writes?