-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-workflow.ts
46 lines (40 loc) · 963 Bytes
/
start-workflow.ts
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
import SWF = require("aws-sdk/clients/swf");
import { initAws, SWF_DOMAIN, SWF_WORKFLOW } from "./config";
import { v4 as uuid } from "uuid";
import chalk from "chalk";
initAws();
const swf = new SWF();
async function startWorkflow(): Promise<{
workflowId: string;
run: SWF.Types.Run;
}> {
const workflowId = uuid();
const run: SWF.Types.Run = await swf
.startWorkflowExecution({
domain: SWF_DOMAIN,
workflowId,
workflowType: { name: SWF_WORKFLOW, version: "1.0" },
input: "ls",
childPolicy: "TERMINATE"
})
.promise();
return {
workflowId,
run
};
}
console.log("Starting a new workflow.");
startWorkflow().then(
response => {
console.log(
chalk.green(
`Workflow started. Workflow ID: ${response.workflowId}. Run ID: ${
response.run.runId
} `
)
);
},
reason => {
console.log(chalk.red("Failed to start workflow. Reason: "), reason);
}
);