New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

codedeploy-scripts

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codedeploy-scripts

AWS CodeDeploy lifecycle scripts using ES6 to deploy a node app to EC2

Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
25
-16.67%
Maintainers
1
Weekly downloads
 
Created
Source

CodeDeploy Scripts

Codeship Status for tqc/codedeploy-scripts

AWS CodeDeploy lifecycle scripts using ES6 to deploy a node app to EC2.

Usage

npm install codedeploy-scripts

In the app folder, you only need two simple files to handle the deployment.

###appspec.yml

This tells CodeDeploy to copy everything to /apps/appname and run deployment.js for all lifecycle events. ApplicationStop is omitted, but you can use it if you are extremely confident in the quality of your code, or just enjoy manually fixing broken servers.

version: 0.0
os: linux
files:
    + source: /
      destination: /apps/appname
hooks:
#  ApplicationStop:
#    - location: deployment.js
#      timeout: 180
  BeforeInstall:
    + location: deployment.js
      timeout: 180
  AfterInstall:
    + location: deployment.js
      timeout: 180
  ApplicationStart:
    + location: deployment.js
      timeout: 180
  ValidateService:
    + location: deployment.js
      timeout: 180

deployment.js

Extends the deployment class with any custom actions needed on CodeDeploy lifecycle events. Deployment.run() will call the appropriate method based on the LIFECYCLE_EVENT variable set by CodeDeploy.

The below code will run /apps/deploytest/server.js on port 5000, with nginx as a reverse proxy and serving static files on deploytest.example.com:80

#!/usr/local/bin/node
"use strict";
var deployTools = require("codedeploy-scripts");
class Deployment extends deployTools.Deployment {
    constructor() {
        this.node = new deployTools.Node("deploytest", 5000, "server.js");
        this.nginx = new deployTools.Nginx(this.node, "deploytest.example.com");
        super();
    }
    BeforeInstall() {
        this.node.stop();
    }
    AfterInstall() {
        this.nginx.configure();
    }
    ApplicationStart() {
        this.node.start();
        this.nginx.reload();
    }
}
new Deployment().run();

Assumptions

To keep things simple, the code makes a few assumptions.

  • The target is a standard Amazon Linux instance
  • io.js is installed as /usr/local/bin/node
  • The app will be installed to /apps/appname
  • static files are in /apps/appname/static and /apps/appname/built

Keywords

AWS

FAQs

Package last updated on 27 Aug 2015

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