forked from davidgf/serverless-plugin-canary-deployments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhooks.js
36 lines (28 loc) · 1.31 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
const aws = require('aws-sdk')
const codedeploy = new aws.CodeDeploy({ apiVersion: '2014-10-06' })
module.exports.pre = (event, context, callback) => {
var deploymentId = event.DeploymentId
var lifecycleEventHookExecutionId = event.LifecycleEventHookExecutionId
console.log('Check some stuff before shifting traffic...')
var 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) => {
var deploymentId = event.DeploymentId
var lifecycleEventHookExecutionId = event.LifecycleEventHookExecutionId
console.log('Check some stuff after shifting traffic...')
var 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')))
}