Processes amarsys recomnendation updates from emarsys-recommendation-updates
SQS and updates EmarsysReommendaions
DynamoDB Table
Expects SQS messages with the following SQS body
attribute:
{
"user_id": Number,
"payload": {
"event_type": String, // one of ['add', 'delete'],
"email_hash": String, // SHA256 hash of email address of customer
// required for 'add*' events only ! - the product recommendation will be presented to the customers in our communication
"predictSecret": String,
"predictUserID": String
}
}
Updates EmarsysRecommendations
DynamoDB table that uses event_type
and user_id
as the primary key.
Moves unprocessable SQS messages to emarsys-recommendation-updates-failed
deadletter SQS queue after 3 unssucessful receives.
add
- adds or overwrites subscriber entry without letting the entry expire automaticallydelete
- delete subscriber
This Lambda application is using AWS SAM to configure, bootstrap and deploy the whole SQS->Lambda->DynamoDB infrastructure (see ./template.yml
).
To run this locally you will need to have the AWS SAM CLI installed and Docker (if you want to invoke the Lambda locally)
# Build Lambdas with AWS SAM
sam build
# Invoke Lambda with example event (see ./events/* for other test events)
# Note: The event will be running against the actual production DynamoDB
sam local invoke --event events/add-event-sqs.json
All automated tests are placed in ./__tests__
and are executed with Jest.
npm test