-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.js
40 lines (33 loc) · 1.06 KB
/
index.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
/**
* AWS Lambda function that is periodically invoked to to start an
* AWS CodePipeline pipeline.
*
* Event Flow:
* 1. A trigger (such as an AWS CloudWatch Event) invoked the Lambda function
* 2. The lambda function executes the specified CodePipeline pipeline using the input pipeline name
*
* @param event AWS event object containing event data
* @param context execution context of the function
* @param callback Optional callback to return information to the caller.
*/
exports.handler = function(event, context, callback) {
"use strict";
// Retrieve the CodePipeline name
const pipelineName = event.pipelineName;
// AWS SDK
const AWS = require('aws-sdk');
//Instantiate CodePipeline
let codepipeline = new AWS.CodePipeline();
let params = {
name: pipelineName
};
codepipeline.startPipelineExecution(params, function(err, data) {
if (err) {
console.log(err, err.stack); // an error occurred
}
else {
console.log(data); // successful response
}
});
callback(null, 'Periodic CodePipeline Executor.');
}