Last active
February 20, 2018 14:44
-
-
Save PaulDuvall/2d688224680ed81172912e6d1a9e0cb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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