I have successfully tested dynamodb.transactWriteItems using VS Code (node js) but when I moved my code to Lambda, it always throws the Type Error: dynamodb.transactWriteItems is not a function. Note that I am NOT using documentClient so declaring dynamodb = new AWS.DynamoDB()
is not the solution.
How can I check the AWS-SDK used by Lambda (my npm aws-sdk is v2.372.0) and how do I make use of the proper AWS-SDK version on Lambda if this is the root cause of the issue?
data = await dynamodb.transactWriteItems({
ReturnConsumedCapacity: "INDEXES",
ReturnItemCollectionMetrics: "SIZE",
TransactItems: [
{
Put: {
TableName: envVarPOTableName,
Item: {
"poNumber": {S: poNumber},
"supplierName": {S: event.supplierName},
"poStatus" : {S: "Created"},
"rmItemsArr": {L: [
{ M:{
"type": {S:event.rmItemObj.type},
"description": {S:event.rmItemObj.description}
},
}
]}
}
}
},
{
Update: {
TableName: envVarRMTableName,
Key:{
"type": {S: event.rmItemObj.type},
"description": {S: event.rmItemObj.description}
},
UpdateExpression: "set #pnA = list_append(#pnA, :vals)",
ExpressionAttributeNames: {
"#pnA" : "poNumbersArr"
},
ExpressionAttributeValues:{
":vals" : {L:[{S:poNumber}]}
},
ReturnValuesOnConditionCheckFailure: "ALL_OLD"
}
}
]
}).promise();