-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.js
40 lines (32 loc) · 1.36 KB
/
hooks.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
const aws = require("aws-sdk");
const codedeploy = new aws.CodeDeploy({ apiVersion: "2014-10-06" });
module.exports.pre = (event, context, callback) => {
const deploymentId = event.DeploymentId;
const lifecycleEventHookExecutionId = event.LifecycleEventHookExecutionId;
console.log("Check some stuff before shifting traffic...");
const params = {
deploymentId: deploymentId,
lifecycleEventHookExecutionId: lifecycleEventHookExecutionId,
status: "Succeeded", // status can be 'Succeeded' or 'Failed'
};
return codedeploy
.putLifecycleEventHookExecutionStatus(params)
.promise()
.then((data) => callback(null, "Validation test succeeded"))
.catch(() => callback(new Error("Validation test failed")));
};
module.exports.post = (event, context, callback) => {
const deploymentId = event.DeploymentId;
const lifecycleEventHookExecutionId = event.LifecycleEventHookExecutionId;
console.log("Check some stuff after shifting traffic...");
const params = {
deploymentId: deploymentId,
lifecycleEventHookExecutionId: lifecycleEventHookExecutionId,
status: "Succeeded", // status can be 'Succeeded' or 'Failed'
};
return codedeploy
.putLifecycleEventHookExecutionStatus(params)
.promise()
.then((data) => callback(null, "Validation test succeeded"))
.catch(() => callback(new Error("Validation test failed")));
};