AWS CodePipeline
  • 2 Minutes to read
  • Dark
  • PDF

AWS CodePipeline

  • Dark
  • PDF

Article summary

If you are using AWS CodePipeline for your CI/CD pipeline, you can integrate Retrace's Deployment API as part of your configuration. The Deployments API offers three different actions (Start, Complete, and Cancel) that can be passed as arguments depending on how you are configuring the Action within your existing CodePipeline. Check out our Deployment Tracking Overview guide to learn how these deployment notifications can be used within Retrace.

This example will cover creating an Action that invokes a Lambda function using Node.js to notify Retrace of a deployment.

Add an Action to your CodePipeline

Depending on how your pipeline is configured, you may want to notify Retrace when a deployment is Started and again when it is Cancelled or Completed. You can pass in the name of the deployment request action as a User Parameter.

The simplest way to notify Retrace of deployments is to send a single Complete requests once the deployment has succeeded. This will create a deployment request and mark it complete with one call.

Upload your Lambda function

This example uses a Lambda function with Node.js 6.10 set as the runtime. The Request npm package needs to be included in the zip file that is uploaded.

var request = require("request");
exports.handler = (event, context, callback) => {

    var app =;
    var env = event.env;
    var version = event.version;

    var apiKey = process.env.apiKey;
	var options = {
		method: 'POST',
		url: '',
		headers: { 
			'Content-Type': 'application/x-www-form-urlencoded',
			Authorization: 'ApiKey ' + apiKey 
		 Version: version,
		 AppName: app,
		 EnvironmentName: env 

	request(options, function (error, response, body) {
	  if (error) throw new Error(error);


Set the variables for your Lambda function

The above Lambda function is expecting our App Name, Post Action, and Version number to be passed in through the event data object. Depending on which CI/CD tools you are are hooking into your pipeline, you should also be able to access variables for Project Name, Branch, or Commit that Retrace's Deployment Tracking API also accepts.

  "env": "Production",
  "version": "v1.0"

The function is also expecting the API Key and Environment name to be set as Environment variables, like this:

Configure Action to invoke your Lambda function

Choose Invoke as the action category and AWS Lambda for the Provider. From the Function name dropdown, choose the Lambda function you uploaded in the step above.

View Deployments in Retrace

You should see the results in your logs after running the plan.

If the plan ran successfully you should now be able to check in Retrace for your deployment requests: You can learn more about viewing deployment history.

Once a Deployment Request has been marked as Complete, it may take a bit before the Deployment flags show up throughout the Retrace UI. Completed deployment requests are processed by the client 5 min maintenance job to create the deployment record.

Was this article helpful?

What's Next