-
Notifications
You must be signed in to change notification settings - Fork 102
/
index.js
55 lines (47 loc) · 1.58 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
const log = require('@cumulus/common/log');
const Task = require('@cumulus/common/task');
const docClient = require('@cumulus/common/aws').dynamodbDocClient();
/**
* Task that deletes ingest tracking data when ingest completes.
* Input payload: An object with the keys given in the output_keys configuration parameter and
* possibly others.
* Output payload: The value of the keys given in the output_keys configuration parameter.
*/
module.exports = class DeleteIngestTrackingData extends Task {
/**
* Main task entry point
*
* @returns {*} Any An object/array, etc., that consists of the value of given key in the
* message payload
*/
async run() {
const message = this.message;
const tableName = this.config.ingest_tracking_table;
const granuleId = this.config.granule_meta.granuleId;
const version = this.config.granule_meta.version;
const payload = message.payload;
// Delete the tracking data for the given granule from DynamoDB
// This should be abstracted out to allow other key stores to be used. See
// JIRA issue GITC-557
const params = {
TableName: tableName,
Key: {
'granule-id': granuleId,
version: version
}
};
log.debug(`Deleting ingest tracking for [${granuleId}]`);
await docClient.delete(params).promise();
return payload;
}
/**
* Entry point for Lambda
*
* @param {Array} args - The arguments passed by AWS Lambda
* @returns {*} The handler return value
*/
static handler(...args) {
return DeleteIngestTrackingData.handle(...args);
}
};