dynamodb.transactWriteItems is not a function error on Lambda but not when using VS Code

The issue is that AWS lambda currently supports AWS SDK for JavaScript – 2.290.0 Ref. DynamoDB transactions are implemented from version 2.365.0 Ref. To solve this you can try including the latest version of JavaScript SDK in your Lambda deployment package Ref.


I managed to initially double confuse myself on this, so thought I'd share in case anyone else did the same thing...

My problem was I was using: const dynamoDB = new AWS.DynamoDB.DocumentClient()

and trying to call .transactWriteItems which isn't valid. If you're using the DocumentClient, you need to use .transactWrite instead.

To use .transactWriteItems your dynamodb has to be set like const dynamoDB = new AWS.DynamoDB()

As @schof said above, the latest lambda aws sdks will support this f() https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html (up to 2.488.0 as of this writing for both 10.x and 8.10)