🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

@teamgantt/pipeline-lambda

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teamgantt/pipeline-lambda

Utilities for lambdas that execute in the context of a CodePipeline

latest
npmnpm
Version
1.0.1
Version published
Weekly downloads
0
-100%
Maintainers
3
Weekly downloads
 
Created
Source

pipeline-lambda

Utilities for lambdas that execute in the context of a CodePipeline

Usage

These functions are mostly boilerplate for lambda functions that execute as a step in AWS CodePipeline.

const AWS = require('aws-sdk');
const {putJobFailure, putJobSuccess} = require('@teamgantt/pipeline-lambda');

// A function that cleans up some temporary test stack
const deleteStack = (cfn, stackName) => {
  const params = {
    StackName: stackName
  };
  return cfn.deleteStack(params).promise();
}

exports.handler = async (event, context) => {
  // Get the job from the event given to lambda
  const job = event['CodePipeline.job'];

  // Get data passed to the job
  const { id: jobId, data: { actionConfiguration: { configuration: { UserParameters: stackName } } } } = job;

  // Create the clients you need for whatever jam your lambda is doing
  const pipeline = new AWS.CodePipeline();
  const cfn = new AWS.CloudFormation();

  try {
    await deleteStack(cfn, stackName);
    // If your work succeeds, call putJobSuccess like so to mark the pipeline job as good
    // this will cause your pipeline to transition to the next step in the pipeline :)
    await putJobSuccess(pipeline, {context, jobId, message: `Deleted stack ${stackName}`});
  } catch (e) {
    // Mark the job as a failure, causing your pipeline to stop dead in it's tracks with failure
    await putJobFailure(pipeline, {context, jobId, message: `Failed to delete stack ${stackName}`});
  }
};

Keywords

aws

FAQs

Package last updated on 05 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts