Skip to content

Instantly share code, notes, and snippets.

@PaulDuvall
Last active February 20, 2018 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulDuvall/2d688224680ed81172912e6d1a9e0cb8 to your computer and use it in GitHub Desktop.
Save PaulDuvall/2d688224680ed81172912e6d1a9e0cb8 to your computer and use it in GitHub Desktop.
CodePipelineParameter:
Type: "AWS::SSM::Parameter"
Properties:
Name: "CodePipelineStack"
Type: "String"
Value:
Ref: CodePipelineStack
Description: "Name of the CodePipeline generated in this CloudFormation template."
=====
AutoTrigger:
Type: AWS::Serverless::Function
Properties:
Handler: indexcpl.handler
Runtime: nodejs6.10
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'AWS::StackName', 'LambdaTrustRole']]
Events:
Timer:
Type: Schedule
Properties:
Schedule: rate(6 hours)
======
var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
const codepipeline = new AWS.CodePipeline();
const ssm = new AWS.SSM();
var iCodePipelineStack = "";
function getCodePipelineStack(callback) {
var params = {
Name: 'CodePipelineStack', /* required */
WithDecryption: false
};
ssm.getParameter(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else iCodePipelineStack = data.Parameter['Value']; callback(); // successful response
});
}
exports.handler = function(event, context) {
getCodePipelineStack(function() {
console.log(iCodePipelineStack);
var params = {
name: iCodePipelineStack
};
codepipeline.startPipelineExecution(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment