Last active
February 15, 2021 07:40
-
-
Save owfm/ee399ebff6e604e753fbae60696a340d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// handleDecisions.js | |
import handler from "./libs/handler-lib"; | |
import AWS from "aws-sdk"; | |
var stepfunctions = new AWS.StepFunctions(); | |
var client = new AWS.DynamoDB.DocumentClient(); | |
export const call = handler(async (event, context) => { | |
const body = JSON.parse(event.body); | |
var sf_params = { | |
output: JSON.stringify(body.decision), | |
taskToken: body.taskToken, | |
}; | |
var db_params = { | |
TableName: process.env.promotionsTable, | |
Key: { taskToken: body.taskToken }, | |
UpdateExpression: "SET decisionStatus = :decisionStatus", | |
ExpressionAttributeValues: { | |
":decisionStatus": body.decision, | |
}, | |
ReturnValues: "ALL_NEW", | |
}; | |
return await Promise.all([ | |
stepfunctions.sendTaskSuccess(sf_params).promise(), | |
client.update(db_params).promise(), | |
]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment