Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapiest-lambda-deploy

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapiest-lambda-deploy

Package that makes deploying AWS Lambda Functions simple and easy

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

Hapiest-lambda-deploy is designed to make it super-simple to deploy one or more lambda functions in a repository.

Setup

  1. Create a deploy config folder with the following files:

    i. deployConfig.json (see example below)

    {
      "lambdaFunctions": [{
        "functionName": "hapiestLambdaDeployTest",
        "zipContents": [
          "index.js",
          "lib"
        ],
        "environments": [
          {
            "envName": "env1",
            "nodeEnvValue": "environment1",
            "liveAliasName": "LIVE"
          }, {
            "envName": "env2",
            "nodeEnvValue": "environment2",
            "liveAliasName": "LIVE"
          }
        ]
      }]
    }
    

    ii. deployCredentials.json (see example below)

    {
      "awsCredentials": {
        "accessKeyId": "someIAMAccessKeyId",
        "secretAccessKey": "someIAMSecretAccessKey",
        "region": "us-east-1"
      }
    }
    
  2. Create a "bin" .js file similar to the one below

    const Promise = require('bluebird');
    const Path = require('path');
    const NodeConfig = require('config');
    const serviceLocator = require('../../services/serviceLocatorFactory').getServiceLocatorSingleton(NodeConfig);
    const logger = serviceLocator.getLogger();
    
    /** @type {DeployLambdaServiceFactoryFolders} */
    const folders = {
        config: Path.resolve(__dirname, '../config'),
        projectRoot: Path.resolve(__dirname, '../..')
    };
    const DeployServiceFactory = require('hapiest-lambda-deploy');
    const deployService = DeployServiceFactory.create(folders, logger);
    
    deployService.deployFromCommandLineArguments(process.argv)
    .then(() => process.exit())
    .catch(err => logger.error('Deploy failed', err));
    
  3. Update package.json to make it easy to deploy using "npm run ..."

    {
        "scripts": {
            "git:ensureClean": "test -z \"$(git status --porcelain)\" || (echo \"Dirty working directory - aborting\" && test -n \"\")",
            "deploy:env1": "npm run git:ensureClean && node deploy/bin/deploy.js -f hapiestLambdaDeployTest -e env1 -c $(git rev-parse HEAD)"
        }
    }
    

    Note, you want to ensure that you have a clean directory so that you don't accidentally deploy code that hasn't been tested / check in. You can optionally remove git:ensureClean step if you like playing Russian Roulette.

  4. Deploy the Lambda function by running

    npm run deploy:env1
    

Running the tests

Currently there's only a single integration test. I plan to add unit tests at some later point in time. To get the integration test up and running, you should:

  1. Create test/helper/integration/config/deployCredentials.json file with valid credentials from Setup step 1

  2. Create an AWS Lambda function with the name hapiestLambdaDeployTest_env1 and a corresponding alias named LIVE

  3. Check that the test runs using npm run test:integration

Keywords

FAQs

Package last updated on 22 Sep 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc