Skip to content
AWS Lambda Function to start a specified AWS CodePipeline
Branch: master
Clone or download
Pull request Compare This branch is even with afajem:master.
Niran Fajemisin
Niran Fajemisin Added labels to diagram
Latest commit 893e950 Dec 29, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Initial commit Dec 21, 2016
.gitignore Initial commit Dec 21, 2016
LICENSE Initial commit Dec 21, 2016 Initial commit Dec 21, 2016
codepipelineexecutor.png Added labels to diagram Dec 28, 2016
package.json Slight change to project description Dec 21, 2016

CodePipeline Executor - An AWS Lambda-based CodePipeline invoker


A key component to a build system is the ability to periodically run the build (and deployment process). AWS CodePipeline currently does not appear to provide this function (at least to the best of my knowledge). AWS however has the building blocks needed to schedule tasks to be periodically executed as well as orchestrating the invocation of AWS services using the AWS SDK. There are two AWS services that provide these functions:

  • AWS Lambda - Allows for a snippet of code to be executed based on a predefined trigger
  • AWS CloudWatch - Provides a mechanism for scheduling tasks to be executed

How does it work?

The execution flow of this AWS Lambda function is depicted in the diagram below:

AWS Lambda call flow

An AWS CloudWatch event rule is defined to specify the schedule that dictates the frequency of invocation. The rule will invoke the AWS Lambda function that has been created, passing in the name of the AWS CodePipeline to be started. The AWS Lambda function will start the CodePipeline represented by the input pipeline name.


The source code is based on a NodeJS package structure and uses NPM to import libraries that facilitate the core functions. The following are the key files needed:

  • src/index.js: The lambda function used to invoke the CodePipeline
  • package.json: Defines the packaging tasks and the npm modules in use


  • Need to create an AWS account
  • Need to setup AWS CLI with the credentials of your AWS account
  • NodeJS and NPM need to be installed

Setting up the Components

  1. Define an AWS CodePipeline
  2. Define the AWS Lambda function, using the code from index.js
  3. Create an AWS CloudWatch event rule. The rule should define the frequency of execution through a schedule (fixed rate or Cron expression). The target should be the Lambda function created in Step 2 with the Configure Input having a JSON object containing the configuration object (event input values) of the function. The following is an example configuration:
	"pipelineName": "MyFirstPipeline"

Working with the source code

  • Clone or fork this repository
  • Ensure that you've followed the Requirements section above
  • Run npm run build to install dependencies, package the Lambda function and node modules in a zip and finally deploys the Lambda function to AWS using the AWS CLI. Ensure that the AWS Lambda function name matches the name specified in the AWS deployment step in package.json


See LICENSE for further details.

You can’t perform that action at this time.