Skip to content

Instantly share code, notes, and snippets.

@owfm
Last active February 15, 2021 07:40
Show Gist options
  • Save owfm/ee399ebff6e604e753fbae60696a340d to your computer and use it in GitHub Desktop.
Save owfm/ee399ebff6e604e753fbae60696a340d to your computer and use it in GitHub Desktop.
// 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