I have a DynamoDB table with a integer value, which needs to be incremented using Python/Boto3/AWS-Lambda environment.
userMetrics
{
"userid": 1234567890,
"likemetrics": 0,
"lasttimestamp": 1604553995
}
I am trying to increment the likemetrics integer counter using atomic increment method dynamodb: how to increment a value in map, but fails during testing.
responseupd = dydb_usertable.update_item(
Key = {
'userid': 1234567890
},
ExpressionAttributeValues: { ":inc": {N: "1"} },
UpdateExpression: "ADD likemetrics :inc"
})
The error thrown by console is
{
"errorMessage": "Syntax error in module 'lambda_function': unindent does not match any outer indentation level (lambda_function.py, line 34)",
"errorType": "Runtime.UserCodeSyntaxError",
"stackTrace": [
" File \"/var/task/lambda_function.py\" Line 34\n responseupd = dydb_usertable.update_item(\n"
]
}