I’m getting timeout error because need to migrate a dynamodb table to the new one. There are many items in old table.So, i’m using lastevaluatedkey for pagination to read operations, but lambda functions live 15 minutes. So, I create a step function as below:
{
"Comment": "DynamoDB Scan Workflow",
"StartAt": "ScanDynamoDB",
"States": {
"ScanDynamoDB": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:**********:function:dynamo-table-migrator",
"Next": "IsScanComplete"
},
"IsScanComplete": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.LastEvaluatedKey",
"IsPresent": true,
"Next": "ScanDynamoDB"
}
],
"Default": "Done"
},
"Done": {
"Type": "Succeed"
}
}
}
My lambda function’s timeout is 10 minutes. I increased it from 30 seconds and it actually migrate almost half of the table but then again gives error. The error:
The cause could not be determined because Lambda did not return an error type. Returned payload: {"errorMessage":"2024-01-10T06:55:49.427Z 4730971c-c428-4692-aa23-4486932da4f2 Task timed out after 600.18 seconds"}
2
Answers
I hope this is one time process to migrate table: I mean not usual task for you.
Just check once if you can improve process:
Quick Way:
Other Way:
Unfortunately, I do not have enough reputation to comment.
What is the allocated memory for the lambda function?
You could potentially increase it if the load is too heavy. Naturally, this has its limit though and comes at a higher cost.
See also the documentation Lambda Memory Optimization.