n-gdpr-deletion-queue
As part of the GDPR user deletion task, we create Lambdas for each system that stores user data in their databases.
This component helps those Lambdas to consume UUID's in a DyamoDB stream.
Usage
Setup these environment variables in your lambda:
Variable | Value |
---|---|
QUEUE_TABLE_NAME | Name of the DynamoDB table that contains the UUIDs |
QUEUE_REGION | Region of the DynamoDB table |
PROCESSOR_TIMEOUT | Time to process a single UUID (optional - defaults to 30,000 ms) |
Consume the DynamoDB stream event in your handler function.
const processDynamoStreamEvent = require('@financial-times/n-gdpr-deletion-queue').processDynamoStreamEvent;
function processUserId(userId) {
// returns a promise
return Promise.resolve();
}
module.exports.handler = async (event, context, callback) => {
await processDynamoStreamEvent(event, processUserId)
.then(() => {
callback(null, {
statusCode: 200,
headers: {
'content-type': 'text/html'
},
body: 'Done',
isBase64Encoded: false
});
})
.catch((error) => {
callback(null, {
statusCode: 500,
headers: {
'content-type': 'text/html'
},
body: error.message,
isBase64Encoded: false
});
});
};
Remarks
- This component will parse the user ids in the DynamoDB Stream event ands passes them to the processor function in parallel.
- The processor function is expected to return a promise.
- If this promise resolves, the component will delete the id from the DynamoDB table.
- If the promise fails, the id will be marked as
failed
, so that it can be reprocessed.