-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathapp.js
More file actions
46 lines (39 loc) · 1.3 KB
/
app.js
File metadata and controls
46 lines (39 loc) · 1.3 KB
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
//Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
//SPDX-License-Identifier: MIT-0
const { EventBridgeClient, PutEventsCommand } = require("@aws-sdk/client-eventbridge");
exports.lambdaHandler = async (event, context) => {
// Do some stuff here and validate that you've been successful
let valid = {
"valid": true,
"reason": "The plugin works!"
};
// Extract duration and taskToken from the incoming event
var taskToken = event["detail"]["taskToken"];
// Configure the EventBridge client
const eventBridgeClient = new EventBridgeClient();
const eventToSend = {
Entries: [
{
Source: 'video.plugin.TestPlugin',
DetailType: 'plugin-complete',
EventBusName: "default",
Detail: JSON.stringify({"TaskToken": taskToken,"Message":valid})
},
]
};
try {
// Put the event on EventBridge
const command = new PutEventsCommand(eventToSend);
await eventBridgeClient.send(command);
return {
statusCode: 200,
body: "Success!"
};
} catch (error) {
console.error('Error sending event:', error);
return {
statusCode: 500,
body:'Error sending event.'
}
}
}